package file;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileCopy {
public static void main(String[] args) throws IOException {
String filePath = "d:\\news.txt";
String fileGoPath = "e:\\news.txt";
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
try {
fileInputStream = new FileInputStream(filePath);
fileOutputStream = new FileOutputStream(fileGoPath);
byte [] buf = new byte[1024];
int readNum = 0;
while((readNum = fileInputStream.read(buf) )!= -1){
fileOutputStream.write(buf,0,readNum);
}
System.out.println("Copy Finish");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
try {
if (fileInputStream != null){
fileInputStream.close();
}
if (fileOutputStream != null){
fileOutputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
d盘复制到e盘
最新推荐文章于 2024-09-01 15:30:33 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)