java小数组高效拷贝和单个字符拷贝效率对比


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

// 高效字节流赋值
public class Test3 {
	public static void main(String[] args) throws IOException {
		String dio = "01回顾.wmv";
		File f = new File("C:\\Users\\Administrator\\Desktop\\Test",dio);
		File of = new File("C:\\Users\\Administrator\\Desktop\\Test\\tv\\a.wmv");
//		if(!f.exists()) {
//			boolean mkdirs = f.mkdirs();
//			System.out.println(mkdirs);
//		}
		FileInputStream fil = new FileInputStream(f);
		
		FileOutputStream fos = new FileOutputStream(of);
		
		BufferedInputStream  bfi = new BufferedInputStream(fil);
		BufferedOutputStream bfo = new BufferedOutputStream(fos);
		int i = 0;
		//shuzu(bfi, bfo);//247
		//sig(bfi, bfo);//4276
		bfi.close();
		fil.close();
		bfo.close();
		fos.close();
		
		
	}

	private static void sig(BufferedInputStream bfi, BufferedOutputStream bfo) throws IOException {
		int i;
		long s = System.currentTimeMillis();
		while((i = bfi.read()) != -1) {
			bfo.write(i);
		}
		long e = System.currentTimeMillis();
		System.out.println(e-s);
	}

	private static void shuzu(BufferedInputStream bfi, BufferedOutputStream bfo) throws IOException {
		int i;
		byte[] c = new byte[1024];
		long s = System.currentTimeMillis();
		while((i = bfi.read(c)) != -1) {
			bfo.write(c);
		}
		long e = System.currentTimeMillis();
		System.out.println(e-s);
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值