1、File 遍歷本地文件
private static void listFiles(File dir,String path) throws IOException {
//2).獲取此目錄下所有的子文件/子目錄的File[]數(shù)組
File[] fileArray = dir.listFiles();
String temp =path;
//3).遍歷數(shù)組啤月,判斷是否是文件:
if (fileArray != null) {
for (File f : fileArray) {
if (f.isFile()) {
System.out.println(""+path+"/"+f.getName());
}else{
path =path+"/"+f.getName();
listFiles(f,path);
}
path =temp;
}
}
}
2畸冲、刪除文件
file.delete()