#java拷贝文件
public static void Copy(String oldFile,String newFile){
try(FileReader file1 = new FileReader(oldFile);
FileWriter file2 = new FileWriter(newFile)){
char[] data = new char[1024];
StringBuilder sb = new StringBuilder();
while ((file1.read(data))!=-1){
file2.write(data);
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)