It sounds like a typical file attachment, for example, "zip".
The usual way to handle this is to actually have a separate instance of InputStream for each nested logical stream. They will perform the necessary operations in the base phsycial stream, and buffering can be both on the base stream and in the logical stream, depending on what suits best. This means that the logical stream encapsulates all the placement information in the base stream.
You could have some kind of factory method that would have a signature like this:
List<InputStream> getStreams(File inputFile)
You can do the same with OutputStreams.
There are some details of this, but may this be enough for you?
krosenvold
source share