May the FileInputStream.available foolish me?
Posted
by Tom Brito
on Stack Overflow
See other posts from Stack Overflow
or by Tom Brito
Published on 2010-05-07T13:29:03Z
Indexed on
2010/05/07
13:38 UTC
Read the original article
Hit count: 383
This FileInputStream.available() javadoc says:
Returns an estimate of the number of remaining bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.
In some cases, a non-blocking read (or skip) may appear to be blocked when it is merely slow, for example when reading large files over slow networks.
I'm not sure if in this check:
if (new FileInputStream(xmlFile).available() == 0)
can I rely that empty files will always return zero?
© Stack Overflow or respective owner