123456789101112131415161718192021222324252627282930 |
- package J20250725;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo05_FileInputStream
- * @description 复制文件
- * @create 2025/7/25
- */
- public class Demo05_FileCopy {
- public static void main(String[] args) throws IOException {
- long start = System.currentTimeMillis();
- //创建文件字节输入流对象
- FileInputStream fis=new FileInputStream("D:/贺卡/images/blue12.png");
- //创建文件字节输出流对象
- FileOutputStream fos=new FileOutputStream("D:/myImage.png");
- int by; //每一次要读的字节
- while((by=fis.read())!=-1){
- fos.write(by);
- }
- long end = System.currentTimeMillis();
- System.out.println(end-start);
- }
- }
|