The current specification of InputStream.available() says:
Returns the number of bytes that can be read (or skipped over) from this
input stream without blocking by the next caller of a method for this input
stream. The next caller might be the same thread or another thread.
This specification is incomplete: It does not relate the allowed return values
to the number of bytes remaining in the stream. In the case of a file, for
example, the total number of bytes is known and the available() method should
always return the number of bytes remaining. It should not be legal, in
particular, for this method to return a non-zero value when there are in fact
no more bytes to be read, regardless of whether or not the thread will block.
-- mr@eng 2001/1/1