十分不建議初學(xué)的同學(xué)們學(xué)習(xí)老師的編寫習(xí)慣,建議該加中括號的都寫上,老師那樣寫,一是習(xí)慣,二是老師是老師。
2015-04-07
序列化父類構(gòu)造函數(shù)被調(diào)用 是由于創(chuàng)建對象,會依次調(diào)用父類構(gòu)造函數(shù),會序列化無關(guān)
2015-04-06
System.out.println( new String( b ) );
is.close();
OutputStream os = new FileOutputStream( "D:/b.txt" );
os.write( b );
os.close();
is.close();
OutputStream os = new FileOutputStream( "D:/b.txt" );
os.write( b );
os.close();
2015-04-04
File atxt = new File( "D:/a.txt" );
InputStream is = new FileInputStream( atxt );
byte[] b = new byte[is.available()];
is.read( b );
int len = 0;
while ( ( len = is.read() ) != -1 ) {
is.read( b, 0, len );
}
System.out.println( new String( b ) );
is.close();
InputStream is = new FileInputStream( atxt );
byte[] b = new byte[is.available()];
is.read( b );
int len = 0;
while ( ( len = is.read() ) != -1 ) {
is.read( b, 0, len );
}
System.out.println( new String( b ) );
is.close();
2015-04-04
我覺得應(yīng)該直接寫 fr.read(buffer) 比 fr.read(buffer,0,buffer.length) 更好,感覺 buffer.length 是多余的
2015-03-30
我覺得flush()寫在while循環(huán)外比較好,flush()是將未滿的緩存送出去,保證傳輸?shù)耐暾?,寫在while內(nèi)的話,buffer流就相當(dāng)于單字節(jié)傳輸方式,不是一個緩存一個緩存的送出去,效率變低了,buffer只有緩存沒滿而恰好文件讀取完成時才要用到flush(),所以寫在buffer的close()之前就好,不用寫在while內(nèi)
2015-03-21