java中使用IO流复制文件

public class TestIO {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			String in="C:\\Users\\Pei\\Desktop\\b14b9472a2c83047e35c31c91fbb88e3.mp4";
			String out="C:\\Users\\Pei\\Desktop\\电视.mp4";
			BufferedInputStream bis=new BufferedInputStream(new FileInputStream(new File(in)));
			BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(new File(out)));
			byte[]bt=new byte[1024];
			int count;
			while((count=bis.read(bt))!=-1){
				bos.write(bt, 0, count);
			}
			bis.close();
			bos.close();
		} catch (Exception e) {
			e.printStackTrace();
			
		}
	}
}

  

posted @ 2020-09-28 17:01  红尘沙漏  阅读(251)  评论(0编辑  收藏  举报