I need to get a list of all the files in a directory, including files in all the sub-directories. What is the standard way to accomplish directory iteration with Java?
Using org.apache.commons.io.FileUtils
org.apache.commons.io.FileUtils
File file = new File("F:/Lines"); Collection files = FileUtils.listFiles(file, null, true); for(File file2 : files){ System.out.println(file2.getName()); }
Use false if you do not want files from sub directories.