JDK-4067088 : java.io.RandomAccessFile.read returns 0 instead of -1 on EOF
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1997-07-24
  • Updated: 1997-08-25
  • Resolved: 1997-08-25
Related Reports
Duplicate :  
Description
Date: Thu, 24 Jul 1997 16:11:42 +0200
From: ###@###.### (Friedhelm Kunkel)
To: ###@###.###
Subject: read with RandomAccessFile delivers 0 instead of -1 at EOF

When I open a file with the FileInputStream, the "read" gives me a "-1"
if reach EOF.

When I open a file with RandomAccessFile and "r" (maybe also "rw") , the
"data_read = fis.read(data, 0, TRY_COUNT) gives me a "0" if I reach
EOF and not
"-1", I would expect. This could lead to endless loops in file handling.
Maybe
this is an error of the jdk1.1.1, I use. This behaviour is independent of
Solaris or NT.

Comments
EVALUATION This was fixed in 1.1.1, so submitter must have been using 1.1 rather than 1.1.1 as reported. -- mr@eng 8/25/1997
25-08-1997