Example usage for java.io File list

List of usage examples for java.io File list

Introduction

In this page you can find the example usage for java.io File list.

Prototype

public String[] list(FilenameFilter filter) 

Source Link

Document

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

Usage

From source file:com.jeffthefate.stacktrace.ExceptionHandler.java

/**
 * Search for stack trace files.//from   w  w w  .  j av  a  2 s.  co  m
 * @return
 */
private static String[] searchForStackTraces() {
    if (stackTraceFileList != null)
        return stackTraceFileList;
    File dir = new File(G.FILES_PATH + "/");
    // Try to create the files folder if it doesn't exist
    dir.mkdir();
    // Filter for ".stacktrace" files
    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".stacktrace");
        }
    };
    return (stackTraceFileList = dir.list(filter));
}

From source file:edu.monash.merc.util.file.DMFileUtils.java

public static List<String> discoverFileNames(String stagePath, FilenameFilter filter) {

    if (stagePath == null) {
        throw new DMFileException("directory must not be null");
    }//from w w  w  .  j  av a2 s .co  m
    File scannedDir = new File(stagePath);

    if (scannedDir.exists() && scannedDir.isFile()) {
        throw new DMFileException("Destination '" + stagePath + "' exists but is a file");
    }

    if (filter == null) {
        filter = new ScanFileFilter();
    }
    String[] fileNames = scannedDir.list(filter);
    List<String> scannedFiles = new ArrayList<String>();

    for (int i = 0; i < fileNames.length; i++) {
        File file = new File(stagePath + File.separator + fileNames[i]);
        if (file.isFile()) {
            scannedFiles.add(file.getName());
        }
    }
    return scannedFiles;
}

From source file:com.l.notel.notel.org.redpin.android.util.ExceptionReporter.java

/**
 * Search for stack trace files./*  w w w .  ja  va  2s.  co  m*/
 * 
 * @return
 */
private static String[] searchForStackTraces() {
    if (stackTraceFileList != null) {
        return stackTraceFileList;
    }
    File dir = new File(E.FILES_PATH + "/");
    // Try to create the files folder if it doesn't exist
    dir.mkdir();
    // Filter for ".stacktrace" files
    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".stacktrace");
        }
    };
    return (stackTraceFileList = dir.list(filter));
}

From source file:com.nullwire.ExceptionHandler.java

/**
 * Search for stack trace files.//ww w .j  a  va 2 s  . com
 * @return
 */
private static String[] searchForStackTraces() {
    if (stackTraceFileList != null) {
        return stackTraceFileList;
    }
    File dir = new File(G.FILES_PATH + "/");
    // Try to create the files folder if it doesn't exist
    dir.mkdir();
    // Filter for ".stacktrace" files
    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".stacktrace");
        }
    };
    return (stackTraceFileList = dir.list(filter));
}

From source file:org.biopax.validator.Main.java

public static Collection<Resource> getResourcesToValidate(String input) throws IOException {
    Set<Resource> setRes = new HashSet<Resource>();

    File fileOrDir = new File(input);
    if (fileOrDir.isDirectory()) {
        // validate all the OWL files in the folder
        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return (name.endsWith(".owl"));
            }//from   w w w.  ja  v  a  2  s .co m
        };
        for (String s : fileOrDir.list(filter)) {
            String uri = "file:" + fileOrDir.getCanonicalPath() + File.separator + s;
            setRes.add(ctx.getResource(uri));
        }
    } else if (input.startsWith("list:")) {
        // consider it's a file that contains a list of (pseudo-)URLs
        String batchFile = input.replaceFirst("list:", "file:");
        Reader isr = new InputStreamReader(ctx.getResource(batchFile).getInputStream());
        BufferedReader reader = new BufferedReader(isr);
        String line;
        while ((line = reader.readLine()) != null && !"".equals(line.trim())) {
            // check the source URL
            if (!ResourceUtils.isUrl(line)) {
                log.error("Invalid URL: " + line + ". A resource must be either a "
                        + "pseudo URL (classpath: or file:) or standard URL!");
                continue;
            }
            setRes.add(ctx.getResource(line));
        }
        reader.close();
    } else {
        // a single local OWL file or remote data
        Resource resource = null;
        if (!ResourceUtils.isUrl(input))
            input = "file:" + input;
        resource = ctx.getResource(input);
        setRes.add(resource);
    }

    return setRes;
}

From source file:org.kie.server.integrationtests.shared.KieServerBaseIntegrationTest.java

public static void cleanupSingletonSessionId() {
    File tempDir = new File(System.getProperty("java.io.tmpdir"));
    if (tempDir.exists()) {

        String[] jbpmSerFiles = tempDir.list(new FilenameFilter() {

            @Override/*from   ww  w. java2s  . c o m*/
            public boolean accept(File dir, String name) {

                return name.endsWith("-jbpmSessionId.ser");
            }
        });
        for (String file : jbpmSerFiles) {

            new File(tempDir, file).delete();
        }
    }
}

From source file:com.meltmedia.cadmium.core.FileSystemManager.java

public static String[] getFilesInDirectory(String directory, final String ext) {
    File dir = new File(directory);
    if (dir.isDirectory()) {
        String files[] = null;/*from w  w w.  ja  v  a 2 s.c o  m*/
        if (ext != null && ext.length() > 0) {
            files = dir.list(new FilenameFilter() {

                @Override
                public boolean accept(File file, String name) {
                    return !file.isDirectory() && name.endsWith("." + ext);
                }

            });
        } else {
            files = dir.list();
        }
        if (files != null) {
            return files;
        }
    }

    return new String[] {};
}

From source file:com.nullwire.trace.ExceptionHandler.java

/**
 * Search for logfiles.//  w w w . j  a  va  2s.com
 * @return
 */
private static String[] searchForLogs() {
    File dir = new File(G.FILES_PATH + "/");
    // Try to create the files folder if it doesn't exist
    dir.mkdir();
    // Filter for ".log" files
    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".log");
        }
    };
    return dir.list(filter);
}

From source file:com.hp.test.framework.Reporting.Utlis.java

public static int getLastRun(String path) {
    File file = new File(path + "\\results\\");
    String[] directories = file.list(new FilenameFilter() {
        @Override// ww w  .  j a  v a2  s  . c  o  m
        public boolean accept(File current, String name) {
            return new File(current, name).isDirectory();
        }
    });

    String temp_ar[] = directories[0].split("_");
    int max = Integer.parseInt(temp_ar[1]);
    for (int i = 1; i < directories.length; i++) {
        String temp_ar1[] = directories[i].split("_");

        int run = Integer.parseInt(temp_ar1[1]);

        if (run > max) {
            max = run;
        }

    }
    log.info(Arrays.toString(directories));
    log.info("Latest Run" + max);
    return max;
}

From source file:com.nullwire.trace.ExceptionHandler.java

/**
 * Search for stack trace files.// w  w w.jav  a  2 s. c o m
 * @return
 */
private static String[] searchForStackTraces() {
    File dir = new File(G.FILES_PATH + "/");
    // Try to create the files folder if it doesn't exist
    dir.mkdir();
    // Filter for ".stacktrace" files
    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".stacktrace");

        }
    };
    return dir.list(filter);
}