Should be pretty simple: I have an InputStream where I want to peek at (not read) the first two bytes, i.e. I want the ‘current position’ of the InputStream to stil be at 0 after my peeking. What is the best and safest way to do this?
Answer – As I had suspected, the solution was to wrap it in a BufferedInputStream which offers markability. Thanks Rasmus.
For a general InputStream, I would wrap it in a BufferedInputStream and do something like this: