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

為了賬號安全,請及時綁定郵箱和手機立即綁定

同樣的讀取方法,為什沒p1方法比p2快了很多?


package TestDemo;


import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

//批量讀取

public class InputDemo1 {

public static ?void ?p1(String ?fileName) throws IOException{

File file1= new ?File(fileName);

FileInputStream fis= new ?FileInputStream(file1);

byte[] byte1=new ?byte[20*1024];

int b=fis.read(byte1, 0, byte1.length);

int temp=1;

for(int i=0;i<b;i++){

System.out.print(Integer.toHexString(byte1[i]&0xff)+" ?");

if(temp++%10==0){

System.out.println();

}

}

fis.close();

}

public static void ?p2(String fileName) throws IOException{

File file2= new ?File(fileName);

FileInputStream fis2=new ?FileInputStream(file2);

byte[] byte2=new ?byte[20*1024];

int k=0;

int temp2=1;

while((k=fis2.read(byte2, 0, byte2.length))!=-1){

for (int i = 0; i <k; i++) {

System.out.print(Integer.toHexString(byte2[i]&0xff)+" ");

if(temp2++%10==0){

System.out.println();

}

}

}

fis2.close();

}

public static void main(String[] args) {

try {

long start=System.currentTimeMillis();

p1("E:\\JavaWeb.zip");

//p2("E:\\JavaWeb.zip");

long end=System.currentTimeMillis();

System.out.println((start-end)+"ms");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}


}


正在回答

2 回答

這兩種方法有啥區(qū)別?你把p1和p2方法換個位置試試看。

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

p1方法并沒有將文件讀取完整,而方法二讀取完整了

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

舉報

0/150
提交
取消

同樣的讀取方法,為什沒p1方法比p2快了很多?

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

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

幫助反饋 APP下載

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

公眾號

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