递归遍历文件中所有html文件保存
2021-03-14 17:28
标签:保存 lis tput read with sub ati use 遍历文件 递归遍历文件中所有html文件保存 标签:保存 lis tput read with sub ati use 遍历文件 原文地址:https://www.cnblogs.com/hellosiyu/p/12808889.htmlimport 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);
}
}
}
}
上一篇:【短文本】短文本相似度算法研究
下一篇:js里关于各种尺寸的获取