gpt4 book ai didi

java - 从java中的DataInputStream获取当前位置

转载 作者:行者123 更新时间:2023-11-30 04:50:51 26 4
gpt4 key购买 nike

谁能告诉我如何在从 DataInputStream 读取二进制文件时获取索引的当前位置?我见过一个 mark() 方法,但一个是 Boolean 类型,另一个是 void。我需要阅读不同位置的索引才能再次使用它们。

最佳答案

类似的问题以前也有人问过。参见例如 this question .

我不知道还有比这更好的答案了:

A simple solution however, would be to roll your own "CountingInputStream" that extends InputStream and counts the number of bytes read. You would basically just need to override the three read-methods.

也可以直接将其实现为 FilterInputStream。

关于java - 从java中的DataInputStream获取当前位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3465215/

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