I'd like something like a generic, re-usable getPosition() method that will tell me the number of bytes read from the starting point of the stream. Ideally, I would prefer this to work with all InputStreams, so that I don't have to wrap each and every one of them as I get them from disparate sources.
Does such a beast exist? If not, can anyone recommend an existing implementation of a counting InputStream?
解决方案
Take a look at CountingInputStream in the Commons IO package. They have a pretty good collection of other useful InputStream variants as well.