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

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

為什么會出現(xiàn)這樣報錯

http://img1.sycdn.imooc.com//605a90760001fb9c07810387.jpg

public?class?BufferedTest?{
????public?static?void?main(String[]?args)?{
????????FileOutputStream?fos?=?null;
????????FileOutputStream?fos2?=?null;
????????BufferedOutputStream?bos?=?null;

????????try?{
????????????fos?=?new?FileOutputStream("fix.txt");
????????????long?start=System.currentTimeMillis();
????????????for?(?int?i=0?;?i<=100000;?i++?????????)?{
????????????????fos.write('a');
????????????}
????????????long?end?=?System.currentTimeMillis();
????????????System.out.println("fix.txt不用緩沖流寫");
????????????long?time1?=(end-start);
????????????System.out.println("用時"+time1);

????????????bos?=?new?BufferedOutputStream(fos2);
????????????long?start2=System.currentTimeMillis();
????????????for?(?int?i=0?;?i<=100000;?i++?????????)?{
????????????????bos.write('a');
????????????}
//????????????bos.write('a');

????????????long?end2?=?System.currentTimeMillis();
????????????long?time2?=(end2-start2);
????????????System.out.println("fox.txt用緩沖流寫");
????????????System.out.println("用時"+time2);

????????????System.out.println("節(jié)約時間"+(time1-time2));

//????????????bos.flush();
????????????fos.close();
????????????fos2.close();
????????????bos.close();


????????}?catch?(FileNotFoundException?e)?{
????????????e.printStackTrace();
????????}?catch?(IOException?e)?{
????????????e.printStackTrace();
????????}
????}
}

http://img1.sycdn.imooc.com//605a90a400018ca516490207.jpg

正在回答

1 回答

fos2 這個變量沒有進行初始化,所以在使用的時候報了空指針異常,fos2 初始化一下就好,就像你的fos變量一樣:fos?=?new?FileOutputStream("fix.txt");

1 回復 有任何疑惑可以回復我~
#1

maxtas 提問者

謝謝啦
2021-04-23 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么會出現(xiàn)這樣報錯

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

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

幫助反饋 APP下載

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

公眾號

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