Here you can find the source of listFilesByDirectory(String directoryPath, boolean isOnlyFile)
public static File[] listFilesByDirectory(String directoryPath, boolean isOnlyFile)
//package com.java2s; import java.io.File; import java.io.FileFilter; public class Main { public static File[] listFilesByDirectory(String directoryPath, boolean isOnlyFile) { File dir = new File(directoryPath); if (!dir.exists()) { return null; }/* w ww . j a v a2s.co m*/ File[] files = null; if (isOnlyFile) { files = dir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { if (pathname.isFile()) { return true; } return false; } }); } else { files = dir.listFiles(); } return files; } }