Given a Java InputStream, how can I determine the current offset in the stream?

后端 未结 4 2127
轻奢々
轻奢々 2020-12-01 18:30

I\'d like something like a generic, re-usable getPosition() method that will tell me the number of bytes read from the starting point of the stream. Ideally, I

4条回答
  •  死守一世寂寞
    2020-12-01 19:02

    There is also CountingInputStream in Guava.

    Apidocs: https://google.github.io/guava/releases/19.0/api/docs/com/google/common/io/CountingInputStream.html

    Source: https://github.com/google/guava/blob/master/guava/src/com/google/common/io/CountingInputStream.java

提交回复
热议问题