An InputStream doesn't really support this directly. If you need it, the best way would be to extend InputStream and keep count of how many bytes have been read so far. You can see an example of this
here. That's for an OutputStream. But as the second poster says, a solution for InputStream is similar, just with more methods.