[java]代码库
import java.io.*;
public class Chp17_2 { //作业二:文件复制
public static void main(String[] args) {
// TODO 自动生成的方法存根
int c = 0;
String str = "";
try {
InputStreamReader ipsr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(ipsr);
String yuanwenjian = br.readLine();
String xinwenjian = br.readLine();
br.close();
BufferedReader br2 = new BufferedReader(new FileReader(yuanwenjian));
BufferedWriter bw = new BufferedWriter( new FileWriter(xinwenjian));
while((str = br2.readLine()) != null) {
bw.write(str);
bw.newLine();
}
bw.flush();
br2.close();
bw.close();
System.out.println("文件已复制!");
}catch(FileNotFoundException e1) {
System.out.println("找不到指定文件");
}catch(IOException e2){
System.out.println("文件复制错误");
}
}
}