开发者

Is there a way to mark an InputStream twice?

I want to make it so I can call in.mark(512) to limit my stream to 512 bytes. Then, later I wan开发者_运维知识库t to limit my stream to 64 bytes. Can I later call in.mark(64) and then in.reset() but still have the mark of 512 be active? What I'm trying to say is "Can you have a mark() and reset() stack?"


At least for BufferedInputStream, the answer is definitely no. It stores marklimit and markpos fields, which are just simple ints.

You could probably write one, but the functionality is not in the base Java streams.


Sure, that is what inheritance is for. Extend whatever stream class you are working with and overload the mark and reset methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜