Java examples for File Path IO:Directory Content
List only files, not subdirectories, and doesn't list hidden files
import java.io.File; import java.io.IOException; public class Main { public static void main(String[] arg) throws IOException { String path = "c:/test1"; File dir = new File(path); if (dir.isDirectory()) { File[] files = dir.listFiles(); for (File f : files) { if (f.isFile() && !f.isHidden()) System.out.println(f.getName()); }/* w w w.j a v a2 s . c om*/ } } }