import java.io.* ;
public class FileCopy {
public static void main(String[] args) {
String inputFile = "D:/java03/day23/Test.txt" ;
String outputFile = "D:/LX/Test.txt" ;
FileReader r = null;
FileWriter w = null;
try {
r = new FileReader(new File(inputFile));
w = new FileWriter(new File(outputFile));
int b = 0;
while((b = r.read()) != -1) {
w.write(b);
}
w.flush();
}catch(FileNotFoundException ex) {
ex.printStackTrace();
}catch(IOException ex) {
ex.printStackTrace();
}finally {
try{
r.close();
w.close();
}catch(IOException ex) {
ex.printStackTrace();
}
}
System.out.println("复制完成!");
}
}
时间: 2024-11-09 10:12:32