类似于RandomAccessFile的内存字节数组的API? [英] RandomAccessFile-like API for in-memory byte array?

查看:292
本文介绍了类似于RandomAccessFile的内存字节数组的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 RandomAccessFile 替换使用内存字节缓冲区的代码(例如 byte [] ByteArrayInputStream )等衍生物。是否有一些API(字节数组包装?)具有类似于 RandomAccessFile 的接口,其中 seek()并且流式化 read()我可以一对一插入吗?

I need to replace code using RandomAccessFile with one that uses in-memory byte buffer (such as byte[] or derivatives like ByteArrayInputStream). Is there some API (byte array wrapper?) that has interface similar to RandomAccessFile, with seek() and streamish read() which I could plug in one-to-one?

推荐答案

ByteArrayInputStream 可以做到:

ByteArrayInputStream can do it:


  • read()的工作方式相同。

  • seek(n)可以替换为 reset()后跟 skip(n)

  • read() works the same.
  • seek(n) can be replaced with reset() followed by skip(n)

这篇关于类似于RandomAccessFile的内存字节数组的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆