将C:\Java Study Source\1.3\06-File类与IO流\04 IO字节流\1_8_4_02一切皆为字节.avi 复制到C:\File中
package Demo01_OutPutStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Demo06_Copy {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("C:\\Java Study Source\\1.3\\06-File类与IO流\\04 IO字节流\\1_8_4_02一切皆为字节.avi");
FileOutputStream fos = new FileOutputStream("C:\\File\\myCopy.avi");
long star = System.currentTimeMillis();
int len = 0;
while((len = fis.read()) != -1){
fos.write(len);
}
System.out.println("复制完成");
long end = System.currentTimeMillis();
System.out.println("用时" + (end - star) / 1000 + "秒");
}
}
|