gpt4 book ai didi

java - BufferedInputStream.read(byte[] b, int off, int len) 中的 off 参数

转载 作者:行者123 更新时间:2023-12-02 05:33:08 24 4
gpt4 key购买 nike

javadoc 的内容如下。

Parameters:
b - destination buffer.
off - offset at which to start storing bytes.
len - maximum number of bytes to read.

我想确认我对“开始存储字节的偏移量”的理解。这是否意味着 off 是“目标缓冲区 b 中开始存储字节的索引”?听起来确实像 off 的意思。我认为如果 off 是“开始读取字节的 BufferedInputStream 的偏移量”,则该方法更有用,但我想确认一下。我尝试查看源代码,但很难阅读。

附带问题:当读取流的 1024 字节时,这 1024 字节是否总是从流中删除?

最佳答案

Does this mean that off is "the index at the destination buffer b at which to start storing bytes"?

这是 documented :“读取的第一个字节存储到元素b[off]中”。

When 1024 bytes of a stream is read, will the said 1024 bytes always be removed from the stream?

当然,但你似乎真的在问,如果你提供 1024 字节的缓冲区,是否总是会读取 1024 字节。答案是否定的。这是documented :“尝试读取至少一个字节”。

关于java - BufferedInputStream.read(byte[] b, int off, int len) 中的 off 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25320046/

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