Java examples for File Path IO:Directory Content
List all the files in a directory passed to the program as a parameter:
import java.io.File; public class Main { public static void main(String[] args) { String path = args[0];// www .j a v a2s .c o m File dir = new File(path); if (dir.isDirectory()) { File[] files = dir.listFiles(); for (File f : files) { System.out.println(f.getName()); } } else System.out.println("Not a directory."); } }