private static void fileCopy1(File from, File to){
InputStream in = null;
OutputStream out = null;
try{
//定义高效字节流
in = new BufferedInputStream(new FileInputStream(from));
out = new BufferedOutputStream(new FileOutputStream(to));
//传输
int b = 0;
while((b = in.read())!=-1){
out.write(b);
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
assert in != null;
in.close();
assert out != null;
out.close();
}catch(Exception e){
e.printStackTrace();
}finally{
in = null;
out = null;
}
}
}
// 使用字符流复制,只能复制文本文件
private static void fileCopy2(File from,File to){
Reader r &
将A文件的内容复制到B文件
最新推荐文章于 2021-09-17 22:09:14 发布