The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

(null).equals(null) ???

Posted by Chin Loong on November 20, 2001 at 5:27 AM

Hiran,

probably u should change the code to be like this :


BufferedReader fileIn = new BufferedReader(new FileReader("c:\\test.txt"));
String taskNumber;
while(!((taskNumber = fileIn.readLine())==null)) {
//some code}

yup, BufferedReader.readLine() will return null if it reaches end of file, but, when it returns null, u can't call the method equals() because null has no such method ;)

probably it ends the application completely because of NullPointerException.

any differing opinions?



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us