Substreams
add a few convenient sub-streams, none of these should close the encloding stream on close, only complete it's own task:
-
NullTerminatedInputStream
read from stream until 00, of closed tries to skip until 00. -
NullTerminatedOutputStream
write to stream and add a 00 byte on close. -
FramedInputStream
read until a specified frame size. Can be extended to read frame size from input stream. E.g. if given frame size on initialization, will use that, and if not will try to read frame size from stream, defaults to base128 (as it is endian-independent). -
FramedOutputStream
write to stream and flush only on close, including frame size. This will write a frame size, defaulting to base128. Essentially write to a tmpByteArrayOutputStream
and write buffer size and content on close.