Example usage for org.apache.commons.io.filefilter FileFileFilter FILE

List of usage examples for org.apache.commons.io.filefilter FileFileFilter FILE

Introduction

In this page you can find the example usage for org.apache.commons.io.filefilter FileFileFilter FILE.

Prototype

IOFileFilter FILE

To view the source code for org.apache.commons.io.filefilter FileFileFilter FILE.

Click Source Link

Document

Singleton instance of file filter

Usage

From source file:org.nanoko.coffee.mill.processors.CSSFileCopyProcessor.java

private void copyCSSFiles() throws ProcessorException {
    getLog().info("Copying " + source.getAbsolutePath() + " to " + destination.getAbsolutePath());
    // Create a filter for ".css" files
    IOFileFilter cssSuffixFilter = FileFilterUtils.suffixFileFilter(".css");
    IOFileFilter csssFiles = FileFilterUtils.and(FileFileFilter.FILE, cssSuffixFilter);

    // Create a filter for either directories or ".css" files
    IOFileFilter filter = FileFilterUtils.or(DirectoryFileFilter.DIRECTORY, csssFiles);

    // Copy using the filter
    try {/*from w  w  w  . ja  va 2  s  .c om*/
        FileUtils.copyDirectory(source, destination, filter);
    } catch (IOException e) {
        throw new ProcessorException("Cannot copy CSS files", e);
    }
}

From source file:org.nanoko.coffee.mill.processors.JavaScriptFileCopyProcessor.java

private void copyJavascriptFiles() throws ProcessorException {
    getLog().info("Copying " + source.getAbsolutePath() + " to " + destination.getAbsolutePath());
    // Create a filter for ".js" files
    IOFileFilter jsSuffixFilter = FileFilterUtils.suffixFileFilter(".js");
    IOFileFilter jsFiles = FileFilterUtils.and(FileFileFilter.FILE, jsSuffixFilter);

    // Create a filter for either directories or ".js" files
    IOFileFilter filter = FileFilterUtils.or(DirectoryFileFilter.DIRECTORY, jsFiles);

    // Copy using the filter
    try {//  w w w .j  a  v  a2s  .  c o m
        FileUtils.copyDirectory(source, destination, filter);
    } catch (IOException e) {
        throw new ProcessorException("Cannot copy JavaScript files", e);
    }
}

From source file:org.noroomattheinn.visibletesla.AppContext.java

public final File ensureAppFilesFolder() {
    boolean storeFilesWithApp = prefs.storeFilesWithApp.get();
    if (storeFilesWithApp)
        return null;

    File aff = getAppFileFolder();
    if (aff.exists())
        return aff;
    if (aff.mkdir()) {
        // Since we're creating this folder for the first time, we might
        // need to copy over existing files from the app folder.
        // HACK ALERT!! This code should not know the file names of the
        // the files to be copied! This is pure expediency!
        File srcDir = new File(System.getProperty("user.dir"));
        IOFileFilter logFilter = FileFilterUtils.suffixFileFilter(".stats.log");
        IOFileFilter txtFilter = FileFilterUtils.nameFileFilter("cookies.txt", IOCase.INSENSITIVE);
        IOFileFilter filter = FileFilterUtils.and(FileFilterUtils.or(logFilter, txtFilter),
                FileFileFilter.FILE);
        try {/*from  w w w. j a  v  a2  s  .  c om*/
            FileUtils.copyDirectory(srcDir, aff, filter);
        } catch (IOException ex) {
            Dialogs.showWarningDialog(stage, "Unable to copy files to Application File Folder: " + aff,
                    "Warning", "VisibleTesla");
        }

        return aff;
    }

    Tesla.logger.log(Level.WARNING, "Could not create Application Files Folder: {0}", aff);
    return null;
}

From source file:org.pentaho.supportutility.config.retriever.FileExtensionUtil.java

/**
 * Get the Server Xmls from server//from  ww  w.  j  ava 2s.c  o m
 * 
 * @param biPath
 * @param dstPath
 * @return
 */
@SuppressWarnings("deprecation")
public static boolean getServerXmlFile(String biPath, String dstPath) {

    Boolean result = false;
    File srcDir = new File(biPath);
    File dstDir = new File(dstPath);
    IOFileFilter SuffixFilter = FileFilterUtils.suffixFileFilter(SupportUtilConstant.DOT_XML);
    IOFileFilter applySuffixFilter = FileFilterUtils.andFileFilter(FileFileFilter.FILE, SuffixFilter);
    IOFileFilter finalFilter = FileFilterUtils.orFileFilter(applySuffixFilter, DirectoryFileFilter.DIRECTORY);
    try {
        FileUtils.copyDirectory(srcDir, dstDir, finalFilter, false);
        if (deleteEmptyDir(dstDir)) {
            result = true;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}

From source file:org.pentaho.supportutility.config.retriever.FileExtensionUtil.java

/**
 * /* ww  w .  j  a  va2s .  c  o m*/
 * Get the Server Properties from Server
 * 
 * @param biPath
 * @param dstPath
 * @return
 */
@SuppressWarnings("deprecation")
public static boolean getServerProperties(String biPath, String dstPath) {

    Boolean result = false;
    File srcDir = new File(biPath);
    File dstDir = new File(dstPath);
    IOFileFilter SuffixFilter = FileFilterUtils.suffixFileFilter(SupportUtilConstant.DOT_PROP);
    IOFileFilter hibFilter = FileFilterUtils.nameFileFilter(SupportUtilConstant.SPRING_JDBC_PROP);
    FileFilter ignorehibFilter = FileFilterUtils.notFileFilter(hibFilter);
    IOFileFilter ldapFilter = FileFilterUtils.nameFileFilter(SupportUtilConstant.SPRING_LDAP_PROP);
    FileFilter ignoreldapFilter = FileFilterUtils.notFileFilter(ldapFilter);
    IOFileFilter filter1 = FileFilterUtils.asFileFilter(ignorehibFilter);
    IOFileFilter filter2 = FileFilterUtils.asFileFilter(ignoreldapFilter);
    IOFileFilter applyIgnoreFilter = FileFilterUtils.andFileFilter(filter1, filter2);
    IOFileFilter applySuffixFilter = FileFilterUtils.andFileFilter(FileFileFilter.FILE, SuffixFilter);
    IOFileFilter applySuffixIgnore = FileFilterUtils.andFileFilter(applySuffixFilter, applyIgnoreFilter);
    IOFileFilter finalFilter = FileFilterUtils.orFileFilter(applySuffixIgnore, DirectoryFileFilter.DIRECTORY);
    try {
        FileUtils.copyDirectory(srcDir, dstDir, finalFilter, false);
        if (deleteEmptyDir(dstDir)) {
            result = true;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}

From source file:org.pentaho.supportutility.config.retriever.FileExtensionUtil.java

/**
 * Get the Server Batch from Server// w w  w  . j a v a  2 s . c om
 * 
 * @param biPath
 * @param dstPath
 * @return
 */
@SuppressWarnings("deprecation")
public static boolean getServerStartUpFile(String biPath, String dstPath) {

    Boolean result = false;
    File srcDir = new File(biPath);
    File dstDir = new File(dstPath);
    IOFileFilter SuffixFilter = null;
    String os = System.getProperty(SupportUtilConstant.OS_NAME).toLowerCase().substring(0, 3);
    if (os.equals("win")) {
        SuffixFilter = FileFilterUtils.suffixFileFilter(SupportUtilConstant.DOT_BAT);
    } else if (os.equals("lin") || os.equals("mac")) {
        SuffixFilter = FileFilterUtils.suffixFileFilter(SupportUtilConstant.DOT_SH);
    }

    IOFileFilter applySuffixFilter = FileFilterUtils.andFileFilter(FileFileFilter.FILE, SuffixFilter);
    IOFileFilter finalFilter = FileFilterUtils.orFileFilter(applySuffixFilter, DirectoryFileFilter.DIRECTORY);
    try {
        FileUtils.copyDirectory(srcDir, dstDir, finalFilter, false);
        if (deleteEmptyDir(dstDir)) {
            result = true;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}

From source file:org.pentaho.supportutility.config.retriever.FileExtensionUtil.java

/**
 * Get the Tomcat Xmls from Server/* w  w w . jav  a 2 s.  com*/
 * 
 * @param tomPath
 * @param dstPath
 * @return
 */
@SuppressWarnings("deprecation")
public static boolean getTomcatXmlFiles(String tomPath, String dstPath) {

    Boolean result = false;
    File srcDir = new File(tomPath);
    File dstDir = new File(dstPath);
    IOFileFilter SuffixFilter = FileFilterUtils.suffixFileFilter(SupportUtilConstant.DOT_XML);
    IOFileFilter contextFilter = FileFilterUtils.nameFileFilter(SupportUtilConstant.CONT_XML);
    FileFilter ignorecontextFilter = FileFilterUtils.notFileFilter(contextFilter);
    IOFileFilter pentahoFilter = FileFilterUtils.nameFileFilter(SupportUtilConstant.PENT_XML);
    FileFilter ignorepentahoFilter = FileFilterUtils.notFileFilter(pentahoFilter);
    IOFileFilter filter1 = FileFilterUtils.asFileFilter(ignorecontextFilter);
    IOFileFilter filter2 = FileFilterUtils.asFileFilter(ignorepentahoFilter);
    IOFileFilter applyIgnoreFilter = FileFilterUtils.andFileFilter(filter1, filter2);
    IOFileFilter applySuffixFilter = FileFilterUtils.andFileFilter(FileFileFilter.FILE, SuffixFilter);
    IOFileFilter applySuffixIgnore = FileFilterUtils.andFileFilter(applySuffixFilter, applyIgnoreFilter);
    IOFileFilter finalFilter = FileFilterUtils.orFileFilter(applySuffixIgnore, DirectoryFileFilter.DIRECTORY);
    try {
        FileUtils.copyDirectory(srcDir, dstDir, finalFilter, false);
        if (deleteEmptyDir(dstDir)) {
            result = true;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}

From source file:org.sipfoundry.sipxconfig.site.common.AssetSelectorMultiple.java

public IPropertySelectionModel getAssetSelectionModel() {
    File assetDir = new File(getAssetDir());
    // make sure it exists
    assetDir.mkdirs();//from w w w  .ja  v a2 s .co m
    // list only files
    String[] assets = assetDir.list(FileFileFilter.FILE);
    if (assets == null) {
        assets = ArrayUtils.EMPTY_STRING_ARRAY;
    }
    return new StringPropertySelectionModel(assets);
}

From source file:org.sonar.batch.scan.DefaultProjectBootstrapper.java

/**
 * Returns files matching specified pattern.
 *///from ww  w  . j  ava 2  s  .c o m
@VisibleForTesting
protected static File[] getLibraries(File baseDir, String pattern) {
    final int i = Math.max(pattern.lastIndexOf('/'), pattern.lastIndexOf('\\'));
    final String dirPath, filePattern;
    if (i == -1) {
        dirPath = ".";
        filePattern = pattern;
    } else {
        dirPath = pattern.substring(0, i);
        filePattern = pattern.substring(i + 1);
    }
    List<IOFileFilter> filters = new ArrayList<IOFileFilter>();
    if (pattern.indexOf('*') >= 0) {
        filters.add(FileFileFilter.FILE);
    }
    filters.add(new WildcardFileFilter(filePattern));
    File dir = resolvePath(baseDir, dirPath);
    File[] files = dir.listFiles((FileFilter) new AndFileFilter(filters));
    if (files == null) {
        files = new File[0];
    }
    return files;
}

From source file:org.wso2.carbon.registry.extensions.handlers.scm.ExternalContentHandler.java

private void loadRegistryResources(Registry registry, File directory, String workingDir, String mountPoint)
        throws RegistryException {
    File[] files = directory.listFiles((FileFilter) new AndFileFilter(HiddenFileFilter.VISIBLE,
            new OrFileFilter(DirectoryFileFilter.INSTANCE, FileFileFilter.FILE)));
    if (files == null) {
        return;// ww  w . j av  a 2s.  c  o  m
    }
    for (File file : files) {
        if (file.isDirectory()) {
            loadRegistryResources(registry, file, workingDir, mountPoint);
        } else {
            // convert windows paths so that it fits into the Unix-like registry path structure.
            String path = mountPoint + file.getAbsolutePath().substring(workingDir.length()).replace("\\", "/");
            if (!registry.resourceExists(path)) {
                registry.put(path, registry.newResource());
            }
        }
    }
}