Java Folder Read getFilesStartingWith(String dirName, String startsWith)

Here you can find the source of getFilesStartingWith(String dirName, String startsWith)

Description

get Files Starting With

License

Open Source License

Declaration

public static File[] getFilesStartingWith(String dirName, String startsWith) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    private static String startChars;

    public static File[] getFilesStartingWith(String dirName, String startsWith) {
        File dir = new File(dirName);
        startChars = startsWith;/* w  w  w. j a v a2  s. co  m*/

        return dir.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String fileName) {
                return fileName.startsWith(startChars);
            }
        });
    }
}

Related

  1. getFilesOf(File dir)
  2. getFilesOfDirectory(File directory)
  3. getFilesOfTypeInDirectory(File directory, String filetype)
  4. getFilesRegex(final File root, final String[] regex)
  5. getFilesStartingWith(File parentDir, String prefix)
  6. getFileStatus(File file)
  7. getFileString(File file)
  8. getFileString(String filePath)
  9. getFileStringContent(String filename)