Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

int available() method in abstract class java.io.InputStream

807589Aug 2 2008 — edited Aug 3 2008
I can't find any particular reason why this method returns an int value and not a long. It's clearly shown that the java developers thought that an InputStream could have a length that would have to be expressed as a long value, because skip takes a long as an argument.
I first noticed that this method returning an int could be problematic when a program I wrote dealt with a file of over 4 GB. The int available() method in FileInputStream showed it as having only a few hundred megabytes of data in it because available() overflowed the integer value back to a positive number. The obvious workaround is to use long length() in File, but what I was wondering was if there is any reason why available() returns an int?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2008
Added on Aug 2 2008
6 comments
131 views