package jp.co.sanx.pos.event; import java.io.File; import java.io.IOException; /** * 找出一个目录下所有的文件 */ public class testPath { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { File dir = new File("E:\\资料"); listAllFile(dir); } public static void listAllFile(File dir){ if (dir.isDirectory()) { File[] listFile = dir.listFiles(); for (File lf : listFile) { if (lf.isDirectory()) { listAllFile(lf); }else if (lf.isFile()){ System.out.println(lf); } } } } }
对文件的操作比较陌生,学习了下下。。。