Search in sources :

Example 36 with FilenameFilter

use of java.io.FilenameFilter in project jetty.project by eclipse.

the class HpackPerfTest method runStories.

private void runStories(int maxDynamicTableSize) throws Exception {
    // Find files
    File data = MavenTestingUtils.getTestResourceDir("data");
    String[] files = data.list(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            return name.startsWith("story_");
        }
    });
    // Parse JSON
    Map<String, Object>[] stories = new Map[files.length];
    int i = 0;
    for (String story : files) stories[i++] = (Map<String, Object>) JSON.parse(new FileReader(new File(data, story)));
    ByteBuffer buffer = BufferUtil.allocate(256 * 1024);
    // Encode all the requests
    encodeStories(buffer, stories, "request");
    // clear table
    BufferUtil.clearToFill(buffer);
    BufferUtil.flipToFlush(buffer, 0);
    // Encode all the responses
    encodeStories(buffer, stories, "response");
}
Also used : FilenameFilter(java.io.FilenameFilter) FileReader(java.io.FileReader) File(java.io.File) Map(java.util.Map) ByteBuffer(java.nio.ByteBuffer)

Example 37 with FilenameFilter

use of java.io.FilenameFilter in project storm by apache.

the class Localizer method readCurrentBlobs.

// Looks for files in the directory with .current suffix
protected File[] readCurrentBlobs(String location) {
    File dir = new File(location);
    File[] files = null;
    if (dir.exists()) {
        files = dir.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(Utils.DEFAULT_CURRENT_BLOB_SUFFIX);
            }
        });
    }
    return files;
}
Also used : FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 38 with FilenameFilter

use of java.io.FilenameFilter in project jscs-plugin by idok.

the class JscsFinder method searchForJscsRCFiles.

/**
     * find possible jscs rc files
     * @param projectRoot
     * @return
     */
public static List<String> searchForJscsRCFiles(final File projectRoot) {
    FilenameFilter filter = new FilenameFilter() {

        @Override
        public boolean accept(File file, String name) {
            return name.equals(JSCSRC);
        }
    };
    // return Arrays.asList(files);
    List<String> files = FileUtils.recursiveVisitor(projectRoot, filter);
    return ContainerUtil.map(files, new Function<String, String>() {

        public String fun(String curFile) {
            return FileUtils.makeRelative(projectRoot, new File(curFile));
        }
    });
}
Also used : FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 39 with FilenameFilter

use of java.io.FilenameFilter in project head by mifos.

the class DatasetVersionTest method checkDataSetDatabaseVersion.

@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void checkDataSetDatabaseVersion() throws Exception {
    class FileExtensionFilter implements FilenameFilter {

        String prefix = "*";

        String ext = "*";

        public FileExtensionFilter(String prefix, String ext) {
            this.prefix = prefix;
            this.ext = ext;
        }

        @Override
        public boolean accept(@SuppressWarnings("unused") File dir, String name) {
            boolean validFile = false;
            if (name.startsWith(prefix) && name.endsWith(ext)) {
                validFile = true;
            }
            return validFile;
        }
    }
    // FIXME - Path works for maven build but not from eclipse
    // To run this test in eclipse, change path below to: "acceptanceTests/target/test-classes/dataSets"
    File f = new File("target/test-classes/dataSets");
    FileExtensionFilter filter = new FileExtensionFilter("", "dbunit.xml");
    File[] acceptList = f.listFiles(filter);
    for (File element : acceptList) {
        verifyDatabaseVersion(element.getName());
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 40 with FilenameFilter

use of java.io.FilenameFilter in project jop by jop-devel.

the class ClassPath method getClassPath.

/** Checks for class path components in the following properties:
     * "java.class.path", "sun.boot.class.path", "java.ext.dirs"
     *
     * @return class path as used by default by BCEL
     */
public static final String getClassPath() {
    String class_path = System.getProperty("java.class.path");
    String boot_path = System.getProperty("sun.boot.class.path");
    String ext_path = System.getProperty("java.ext.dirs");
    List list = new ArrayList();
    getPathComponents(class_path, list);
    getPathComponents(boot_path, list);
    List dirs = new ArrayList();
    getPathComponents(ext_path, dirs);
    for (Iterator e = dirs.iterator(); e.hasNext(); ) {
        File ext_dir = new File((String) e.next());
        String[] extensions = ext_dir.list(new FilenameFilter() {

            public boolean accept(File dir, String name) {
                name = name.toLowerCase(Locale.ENGLISH);
                return name.endsWith(".zip") || name.endsWith(".jar");
            }
        });
        if (extensions != null) {
            for (int i = 0; i < extensions.length; i++) {
                list.add(ext_dir.getPath() + File.separatorChar + extensions[i]);
            }
        }
    }
    StringBuffer buf = new StringBuffer();
    for (Iterator e = list.iterator(); e.hasNext(); ) {
        buf.append((String) e.next());
        if (e.hasNext()) {
            buf.append(File.pathSeparatorChar);
        }
    }
    return buf.toString().intern();
}
Also used : FilenameFilter(java.io.FilenameFilter) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Aggregations

FilenameFilter (java.io.FilenameFilter)402 File (java.io.File)398 IOException (java.io.IOException)100 ArrayList (java.util.ArrayList)72 Test (org.junit.Test)60 URL (java.net.URL)22 List (java.util.List)22 RandomAccessFile (java.io.RandomAccessFile)19 HashSet (java.util.HashSet)17 FileOutputStream (java.io.FileOutputStream)14 JarFile (java.util.jar.JarFile)14 FileNotFoundException (java.io.FileNotFoundException)13 MalformedURLException (java.net.MalformedURLException)13 HashMap (java.util.HashMap)13 FileFilter (java.io.FileFilter)11 FileWriter (java.io.FileWriter)11 ZipFile (java.util.zip.ZipFile)11 TestClient (org.syncany.tests.util.TestClient)11 FileReader (java.io.FileReader)10 Pattern (java.util.regex.Pattern)10