java中的io流问题 FileInputStream中的read()返回的int类型是读取字节的

java中的io流问题
FileInputStream中的read()返回的int类型是读取字节的ASCLL编码么?是一个一个字节读?
BufferedInputStream中的read()返回的是读入字节的长度吗?是一段一段的读吗?谢谢了,感觉好疑惑

不是,两个都是返回Ascll编码,bufferInputStream是缓冲流,提高效率

追问

谢谢

温馨提示:内容为网友见解,仅供参考
第1个回答  2016-03-29
FileInputStream是基础类,字节流,按字节读取。
BufferedInputStream是包装类,处理流,先将数据读于缓冲区,然后再读取
第2个回答  2016-03-29
看源码啊,FileInputStream

/**
* 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;
}本回答被网友采纳
相似回答