How can I read different groups of data on the same InputStream, using different types of InputStreams for each of them?
问题 I needed to save some data in Java in various ways, to a File , to a String , to System.out ... And I ended up with 3 methods doing pretty much the same thing. So I changed them into a single method with an OutputStream as a parameter. I wrote a few things to a single OutputStream, e.g. some text, a serialized object, another serialized object, some numerical data ... But now I'm stuck. I overlooked the fact that I cannot distinguish between the different things that have been written. I