RandomAccessFile-like API for in-memory byte array?

前端 未结 4 1294
情书的邮戳
情书的邮戳 2021-01-11 16:20

I need to replace code using RandomAccessFile with one that uses in-memory byte buffer (such as byte[] or derivatives like ByteArrayInputStre

4条回答
  •  一个人的身影
    2021-01-11 16:37

    I had the same problem. RandomAccessFile has many finale and native methods, so it cannot be overloaded.

    I ended to create my own SeekableInputStream abstract class by stealing this one without readfully : https://github.com/samtools/htsjdk/blob/master/src/java/htsjdk/samtools/seekablestream/SeekableStream.java

    I defined SeekableFileInputStream which uses RandomAccessFile.

    I defined SeekableByteArrayInputStream, which is easy to define. This class, is also able to get any InputStream, to transform it into a byte array, so this is a kind of cached stream.

提交回复
热议问题