c*********n 发帖数: 128 | 1 今天写程序碰到一个问题, 搞清楚了,
但是由此想到之前在这里问的为什么write()参数为int c问题, 故来讨论一下
用InputStream的read()来从文件中读字节
read
public abstract int read()
throws IOException
Reads the next byte of data from the input stream. The value byte is
returned as an int in the range 0 to 255. If no byte is available because the
end of the stream has been reached, the value -1 is returned. This method
blocks until input data is available, the end of the stream is detected, or an
exception is thrown.
这里读的是byte却用int的形式 | g*****g 发帖数: 34805 | 2 事实上很少有人直接用InputStream,如果处理文本可以
用BufferedReader,传送Object可以用ObjectInputStream,
真是处理视频之类的也可以用ByteArrayInputStream。
the
an
【在 c*********n 的大作中提到】 : 今天写程序碰到一个问题, 搞清楚了, : 但是由此想到之前在这里问的为什么write()参数为int c问题, 故来讨论一下 : 用InputStream的read()来从文件中读字节 : read : public abstract int read() : throws IOException : Reads the next byte of data from the input stream. The value byte is : returned as an int in the range 0 to 255. If no byte is available because the : end of the stream has been reached, the value -1 is returned. This method : blocks until input data is available, the end of the stream is detected, or an
| m******t 发帖数: 2416 | 3 Interesting theory. Makes sense to me.
the
an
【在 c*********n 的大作中提到】 : 今天写程序碰到一个问题, 搞清楚了, : 但是由此想到之前在这里问的为什么write()参数为int c问题, 故来讨论一下 : 用InputStream的read()来从文件中读字节 : read : public abstract int read() : throws IOException : Reads the next byte of data from the input stream. The value byte is : returned as an int in the range 0 to 255. If no byte is available because the : end of the stream has been reached, the value -1 is returned. This method : blocks until input data is available, the end of the stream is detected, or an
|
|