递归遍历文件中所有html文件保存
import java.io.*;
public class Test {
public static void main(String[] args) throws IOException {
File file = new File("/Users/mima000000/Desktop/health/讲义");
te(file);
}
public static void te(File file) throws IOException {
File[] files = file.listFiles();
for (File file1 : files) {
if (file1.isFile()){
if (file1.toString().endsWith(".html")){
String name = file1.getName();
String resname = name.substring(0, name.lastIndexOf("."));
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file1));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("/Users/mima000000/Desktop/health/res/"+resname+".html")));
int len;
byte[] content = new byte[1024*10];
while ((len = (bis.read(content)))!= -1){
bos.write(content,0,len);
}
}
}else {
te(file1);
}
}
}
} 相关推荐
大地飞鸿 2020-11-12
steeven 2020-11-10
Tips 2020-10-14
nongfusanquan0 2020-08-18
yedaoxiaodi 2020-07-26
夜晚00 2020-07-03
hanyujianke 2020-06-28
xhao 2020-06-28
清溪算法君老号 2020-06-27
pengkingli 2020-06-25
yishujixiaoxiao 2020-06-25
Masimaro 2020-06-21
清溪算法 2020-06-21
oXiaoChong 2020-06-20
RememberMePlease 2020-06-17
chaigang 2020-06-13