标签:byte 输出流 final mil 定义 tar new oid str
public void myTest() { // 定义输入和输出流 FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream("E:\\电影\\黄飞鸿之铁鸡斗蜈蚣.mkv"); fos = new FileOutputStream("F:\\黄飞鸿之铁鸡斗蜈蚣.mkv"); byte[] b = new byte[1024]; int len = 0; long start = System.currentTimeMillis();// 记录开始复制的时间 while ((len = fis.read(b)) != -1) { fos.write(b, 0, len); } long end = System.currentTimeMillis();// 记录结束复制的时间 System.out.println(end - start);// 算出复制文件所用的时间(ms) } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) { fos.close(); } if (fis != null) { fis.close(); } } catch (IOException e) { e.printStackTrace(); } } }
2、
public void myTest() { // 定义输入和输出流 BufferedInputStream bfis = null; BufferedOutputStream bfos = null; try { bfis = new BufferedInputStream(new FileInputStream("E:\\电影\\黄飞鸿之铁鸡斗蜈蚣.mkv")); bfos = new BufferedOutputStream(new FileOutputStream("F:\\黄飞鸿之铁鸡斗蜈蚣.mkv")); byte[] b = new byte[1024]; int len = 0; long start = System.currentTimeMillis();// 记录开始复制的时间 while ((len = bfis.read(b)) != -1) { bfos.write(b, 0, len); } long end = System.currentTimeMillis();// 记录结束复制的时间 System.out.println(end - start);// 算出复制文件所用的时间(ms) } catch (IOException e) { e.printStackTrace(); } finally { try { if (bfos != null) { bfos.close(); } if (bfis != null) { bfis.close(); } } catch (IOException e) { e.printStackTrace(); } } }
标签:byte 输出流 final mil 定义 tar new oid str
原文地址:http://www.cnblogs.com/a591378955/p/7860130.html