import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Copy_File {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
copyFile();
}
private static void copyFile() throws IOException{
try (
FileInputStream fis = new FileInputStream("G:/0322/day01/video/1.avi");
FileOutputStream fos = new FileOutputStream("C:/day20.avi");
) {
int x;
byte[]b = new byte[1024];
while((x = fis.read(b)) != -1) {//循环读取关联文件中的内容
fos.write(b,0,x);//写入指定文件中的内容到指定文件
}
}
}
}
仅供参考,为了容易理解,我加了注释,希望能帮到您 |