JDK-4401029 : (spec) InputStream.available should specify behavior wrt. EOF
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-01-01
  • Updated: 2005-09-01
  • Resolved: 2005-09-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b45Fixed
Related Reports
Relates :  
Relates :  
Description
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

Comments
EVALUATION Should specify that "returns 0 when it reaches the end of the input stream." ###@###.### 2005-05-20 10:06:02 GMT
20-05-2005