3 回答

TA貢獻1801條經(jīng)驗 獲得超8個贊
FileInputStream是基礎類,字節(jié)流,按字節(jié)讀取。
BufferedInputStream是包裝類,處理流,先將數(shù)據(jù)讀于緩沖區(qū),然后再讀取

TA貢獻1829條經(jīng)驗 獲得超7個贊
看源碼啊,F(xiàn)ileInputStream
/**
* Reads a byte of data from this input stream. This method blocks
* if no input is yet available.
*
* @return the next byte of data, or <code>-1</code> if the end of the
* file is reached.
* @exception IOException if an I/O error occurs.
*/
public native int read() throws IOException;
BufferedInputStream
/**
* See
* the general contract of the <code>read</code>
* method of <code>InputStream</code>.
*
* @return the next byte of data, or <code>-1</code> if the end of the
* stream is reached.
* @exception IOException if this input stream has been closed by
* invoking its {@link #close()} method,
* or an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
public synchronized int read() throws IOException {
if (pos >= count) {
fill();
if (pos >= count)
return -1;
}
return getBufIfOpen()[pos++] & 0xff;
}
添加回答
舉報