Java examples for File Path IO:Directory Content
List the name of every file in a directory whose pathname is stored in the String variable path
import java.io.File; import java.io.IOException; public class Main { public static void main(String[] arg) throws IOException { String path = "c:/test"; File dir = new File(path); if (dir.isDirectory()) { File[] files = dir.listFiles(); for (File f : files) System.out.println(f.getName()); }/*from ww w. j a v a 2 s .co m*/ } }