private void getAllFileInfo(String path) { File dirFile = new File(path); File[] files = dirFile.listFiles(); //开始遍历所有文件 for(int i=0;i<files.length;i++) { //子文件 if(files[i].isFile()) { File f = files[i]; System.out.println(f.getName()); } else //文件夹 { File f = files[i]; System.out.println(f.getAbsolutePath()); getAllFileInfo(f.getAbsolutePath()); } } }