package com.jack.io; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class main { public static void main(String[] args) throws Exception { //文件的复制 long s = System.currentTimeMillis(); File file1 = new File("D:\迅雷下载\公牛犹斗.1080p.HD中字.mp4"); File file2 = new File("D:\迅雷下载\公牛犹斗.1080p.HD中字2.mp4"); FileInputStream fileInputStream = new FileInputStream(file1); FileOutputStream fileOutputStream = new FileOutputStream(file2, true); byte[] bs = new byte[1024*1024];
while ((fileInputStream.read(bs)) != -1) { fileOutputStream.write(bs); } fileInputStream.close(); fileOutputStream.close(); long e = System.currentTimeMillis(); System.out.println("复制文件,耗时毫秒:" + (e - s)); } }