标签:system row dwr ack fileread package exception sys copyfile
package com.botao;
import java.io.*;
/**
* @author cbt28
*/
public class FileUtil {
public static String a="";
public static String b="";
public static void copyDir(File src, File target) throws IOException {
if (!target.exists()) {
target.mkdir();
}
File[] lf = src.listFiles();
for (File file : lf) {
if (file.isFile()) {
System.out.println(src + "\\" + file.getName() + "--->" + target + "\\" + file.getName());
boolean b = copyFile(new File(src + "\\" + file.getName()), new File(target + "\\" + file.getName()));
System.out.println(b);
} else {
copyDir(new File(src + "\\" + file.getName()), new File(target + "\\" + file.getName()));
}
}
}
public static boolean copyFile(File src, File target) throws IOException {
FileReader fr = new FileReader(src);
BufferedReader br = new BufferedReader(fr);
FileWriter fw = new FileWriter(target);
BufferedWriter bw = new BufferedWriter(fw);
String s = br.readLine();
while (s != null) {
bw.write(s);
bw.newLine();
s = br.readLine();
}
bw.close();
fw.close();
br.close();
fr.close();
return true;
}
}
标签:system row dwr ack fileread package exception sys copyfile
原文地址:https://www.cnblogs.com/botaoJava/p/13773259.html