第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

對(duì)1.09G文件操作時(shí)間,談及個(gè)人理解

public static void copyFlie(File srcFile ,File destFile) throws IOException {

if(!srcFile.exists()) {

throw new IllegalArgumentException("目標(biāo)文件:"+srcFile +" 不存在");

}

if(!srcFile.isFile()) {

throw new IllegalArgumentException(srcFile+" 不是文件");

}

FileInputStream in = new FileInputStream(srcFile);

FileOutputStream out = new FileOutputStream(destFile);

byte[] buf = new byte[8*1024];

int b;

while((b = in.read(buf, 0, buf.length))!=-1) {

out.write(buf, 0, b);

}

in.close();

out.close();

}

/**

* 進(jìn)行文件的拷貝,利用帶緩存的字節(jié)流

*?

* @param srcFile

* @param destFile

*/

public static void copyByBuffer(File srcFile ,File destFile) throws IOException{

if(!srcFile.exists()) {

throw new IllegalArgumentException("目標(biāo)文件:"+srcFile +" 不存在");

}

if(!srcFile.isFile()) {

throw new IllegalArgumentException(srcFile+" 不是文件");

}

BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcFile));

BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destFile));

byte[] buf = new byte[8*102];

int c;

while((c=bis.read(buf , 0 ,buf.length))!=-1) {

bos.write(buf,0,c);

bos.flush();//刷新緩沖區(qū)

}

bis.close();

bos.close();

}


對(duì)1.09G文件的操作,進(jìn)行五組數(shù)據(jù)對(duì)比,copyFlie平均用時(shí)14093,copyByBuffer當(dāng)flush在循環(huán)外平均用時(shí)13971

由于每次讀取時(shí)間不確定,有的copyfile快于copybybuffere,有的相反,所以感覺(jué)速度不相上下。當(dāng)copybybuffere采用單字節(jié)的時(shí)候,時(shí)間不可想象,太長(zhǎng)了,如果flush在循環(huán)內(nèi)部時(shí)間也會(huì)過(guò)長(zhǎng),沒(méi)有做對(duì)比

正在回答

1 回答

這是為啥。。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

對(duì)1.09G文件操作時(shí)間,談及個(gè)人理解

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)