递归遍历文件中所有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);
}
}
}
}
我对任何唾手而得,快速,出自本能,即兴,含混的事物没有信心。我相信缓慢,平和,细水长流的力量,踏实,冷静。我不相信缺乏自律精神和不自我建设,不努力,可以得到个人或集体的解放。