[java]代码库
public static void main(String[] args) throws Exception {
// 递归显示C盘下所有文件夹及其中文件
File root = new File("G:\\brainsoon\\03_document\\需求\\基础加工培训\\样例\\PDF样例");
showAllFiles(root);
}
final static void showAllFiles(File dir) throws Exception {
File[] fs = dir.listFiles();
for (int i = 0; i < fs.length; i++) {
if (fs[i].getAbsolutePath().endsWith(".pdf")) {
File dd = FileUtils.getFile(fs[i].getAbsolutePath());
String name = dd.getName();
String path = dd.getParent();
System.out.println(name);
System.out.println(path);
System.out.println(fs[i].getAbsolutePath());
}
if (fs[i].isDirectory()) {
try {
showAllFiles(fs[i]);
} catch (Exception e) {
}
}
}