标签:mp4 bis esc time style imp input throw import
package cn.lijun.demo2; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; public class Copy { public static void main(String[] args) throws Exception { long start=System.currentTimeMillis(); copy2(new File("d:\\d.mp4"),new File("c:\\d.mp4")); long end=System.currentTimeMillis(); System.out.println(end-start); } //字节流读取单个字节 public static void copy1(File src,File desc) throws Exception{ FileInputStream fis=new FileInputStream(src); FileOutputStream fos=new FileOutputStream(desc); int len=0; while((len=fis.read())!=-1){ fos.write(len); } fos.close(); fis.close(); } //字节流读写字节数组 5451 public static void copy2(File src,File desc) throws Exception{ FileInputStream fis=new FileInputStream(src); FileOutputStream fos=new FileOutputStream(desc); byte[] b=new byte[1024]; int len=0; while((len=fis.read(b))!=-1){ fos.write(b,0,len); } fos.close(); fis.close(); } //字节流缓冲区 读写单个字节 21208ms public static void copy3(File src,File desc) throws Exception{ BufferedInputStream bis=new BufferedInputStream(new FileInputStream(src)); BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(desc)); int len=0; while((len=bis.read())!=-1){ bos.write(len); } bos.close(); bis.close(); } //字节流缓冲区读写字节数组 5415ms public static void copy4(File src,File desc) throws Exception{ BufferedInputStream bis=new BufferedInputStream(new FileInputStream(src)); BufferedOutputStream bop=new BufferedOutputStream(new FileOutputStream(desc)); int len=0; byte[] b=new byte[1024]; while ((len=bis.read(b))!=-1){ bop.write(b,0,len); } bop.close(); bis.close(); } }
标签:mp4 bis esc time style imp input throw import
原文地址:https://www.cnblogs.com/qurui1998/p/10602793.html