The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

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:

Priting contents in BuferedReader

Posted by Ahmed haq on January 30, 2002 at 9:59 AM

Hey guys,
I am using a BufferedReader to read all the contents in a file.
It does it perfectly. However after reading the file, the program
needs to print all the contents it has read. The only way I am
allowed to do it is AFTER the program has finished reading the file.
Please Help me with this. Here is my code for reading the file.

// CODE

BufferedReader fr = new BufferedReader(new FileReader(nextLine));

//----------------------first element in this file--------------------------

nextLine = fr.readLine();

//----------------------------second element in the file------------------------------

nextLine = fr.readLine();

for(;;){

nextLine = fr.readLine();

if(nextLine == null)
break;
}

// System.out.println(fr.toString()); (this doesn't work)


thanks



Replies:

Sponsored Links



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