What value does readLine() return when it has reached the end of a file

The readLine() method returns null when it has reached the end of a file.

Showing Answers 1 - 6 of 6 Answers

srinivasa reddy

  • Aug 10th, 2005
 

It does not return null value. it return -1when it reaches the end of file

  Was this answer useful?  Yes

Trimoorthy

  • May 19th, 2006
 

No, readLine() method on a bufered reader gives null on reaching end of file. It does not give -1.

  Was this answer useful?  Yes

It returns null because BufferReader object reading the data as string from the file, at the end if the content is not available it returns null.

  Was this answer useful?  Yes

Hanuman Sai

  • Sep 21st, 2015
 

When readLine tries to read beyond the end of a text file it returns the special value null so you can test for null to stop processing a text file

read returns -1 when it tries to read beyond the end of a text file
the int value of all ordinary characters is non-negative

Neither of these two methods (read and readLine) will throw an EOFException.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions