Buffered字符处理流拷贝文件
public class BufferedCopy01 {
public static void main(String[] args) {
String arcFilePath = "D:\\story.java";
String destFilePath = "D:\\story2.java";
BufferedReader br = null;
BufferedWriter bw = null;
String line;
try {
br = new BufferedReader(new FileReader(arcFilePath));
bw = new BufferedWriter(new FileWriter(destFilePath));
while ((line = br.readLine()) != null){
bw.write(line);
bw.newLine();
}
System.out.println("拷贝完毕");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null){
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (bw != null){
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}