int available() method in abstract class java.io.InputStream
807589Aug 2 2008 — edited Aug 3 2008I 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?