The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000



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.


I saw it...

Posted by Kishori Sharan on December 10, 2000 at 8:27 PM

I saw your third line of text. You are reading the first two lines of text in mary and word string variables as shown in bold. Again in first while loop you are using readLine to read a line of text in mary string variable which will read the third line of text in mary. So when you are displaying the text in first while loop you cannot read the second line again. Remedy is just remove the line word = inFile.readLine ( ) and try to rewrite code so that your code after first while loop remains valid.

mary = inFile.readLine();
word = inFile.readLine();

while (mary != null){
StringTokenizer t=new StringTokenizer (mary);
while (t.hasMoreTokens()){
System.out.print(mary+" ");
}//end while

mary = inFile.readLine();

}//end while


Sponsored Links

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