gpt4 book ai didi

java - JAVA中的流结束

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:57:54 27 4
gpt4 key购买 nike

我对出现的以下语句感到困惑here

The basic read() method of the InputStream class reads a single unsigned byte of data and returns the int value of the unsigned byte. This is a number between 0 and 255. If the end of stream is encountered, it returns -1 instead; and you can use this as a flag to watch for the end of stream.

由于一个字节最多可以表示 256 个整数,我看不出它如何表示 0 到 256 和 -1。有人可以评论我在这里缺少的东西吗?

最佳答案

InputStream#read() 的返回类型是一个 int,如果值在 0-255 范围内,则可以将其读取为 byte

关于java - JAVA中的流结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14449473/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com