java读取文件夹下的所有文件夹和文件
来源:长理培训发布时间:2017-12-23 15:15:12
百度广告
以下是实现的代码
package com.borland.samples.welcome;
import java.io.FileNotFoundException;
import java.io.File;
public class ReadFile {
/**
* @param delpath String
* @throws IOException
*/
IOException {
File file = new File(delpath);
System.out.println("1");
}
System.out.println("2");
for (int i = 0; i < filelist.length; i++) {
if (!delfile.isDirectory()) {
System.out.println("absolutepath=" + delfile.getAbsolutePath());
delfile.delete();
}
deletefile(delpath + """" + filelist[i]);
}
}
}
System.out.println("deletefile() Exception:" + e.getMessage());
return true;
/**
* @param delpath String
* @throws IOException
*/
IOException {
File file = new File(filepath);
System.out.println("文件");
System.out.println("absolutepath=" + file.getAbsolutePath());
}
System.out.println("文件夹");
for (int i = 0; i < filelist.length; i++) {
if (!readfile.isDirectory()) {
System.out.println("absolutepath=" + readfile.getAbsolutePath());
}
readfile(filepath + """" + filelist[i]);
}
}
}
System.out.println("readfile() Exception:" + e.getMessage());
return true;
public static void main(String args) {
readfile("D:/file");
}
}
}
}
|
点击加载更多评论>>