avatar
关于char和int的问题# Java - 爪哇娇娃
c*n
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的形式
avatar
g*g
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

avatar
m*t
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

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。