You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Mark Hindess <ma...@googlemail.com> on 2009/11/03 22:29:58 UTC

[classlib] BufferedReader and FileInputStream.available()

Our implementation of BufferedReader calls FileInputStream.available()
while the RI does not.  This is a problem because it means that the RI
can read certain types of files that our implementation can not - such
as /proc/mounts on Linux.  I will investigate this shortly.

While looking at this I notice that our implementation of 
FileInputStream.available() does:

  long currentPosition = fileSystem.seek(fd.descriptor, 0L,
                                         IFileSystem.SEEK_CUR);
  long endOfFilePosition = fileSystem.seek(fd.descriptor, 0L,
                                           IFileSystem.SEEK_END);
  fileSystem.seek(fd.descriptor, currentPosition, IFileSystem.SEEK_SET);
  return (int) (endOfFilePosition - currentPosition);

making three JNI calls.  It might be better to implement this as a
single JNI call - particularly since at the moment we seem to be calling
it more often than the RI.

Comments welcome.
 Mark.