Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > BufferedReader Method to Read Next Line??

Reply
Thread Tools

BufferedReader Method to Read Next Line??

 
 
Krmathieu
Guest
Posts: n/a
 
      12-25-2004
I am working on an application that creates a buffer from a random access file
using the BufferedReader class. I have been able to create the buffer from the
input file and read/then print the first line from the buffer by using the
BufferedReader class method of readLine(). However, I can not find a method
that would enable me to read in the next line. I have included the relevant
code from my app below:

fileName = fileChooser.getSelectedFile();
input = new RandomAccessFile( fileName, "r" );
fileReader = new FileReader( fileName.getName() );
bufferedReader = new BufferedReader ( fileReader );
String line = bufferedReader.readLine();

Does anybody know what method or code could be used to access the next line
of the buffer? Basically, what I am trying to do is read in each individual
line of a file, assign the line to a string variable and then check to see if
the string contains the start of a valid subject. Also, I tried resetting the
starting mark of the read from the buffer by using the reset() method of the
BufferedClass, but I got a compile error stating that the compiler could not
resolve the symbol of reset() even though I have included java.io.* as an
import statement. Any help that anybody could provide would be greatly
appreciated. Thanks.

Kevin
 
Reply With Quote
 
 
 
 
Michael Wong
Guest
Posts: n/a
 
      12-25-2004
"Krmathieu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Does anybody know what method or code could be used to access the next
> line
> of the buffer? Basically, what I am trying to do is read in each
> individual



When working with streams, the current position is the next character that
hasn't been read yet... unless you use the mark/reset methods, which allow
you to set a mark in the stream and reset the position back to that mark.
In your case (BufferedReader), just keep calling the readLine method, it
will return the next line of text. If the readLine method returns null,
you've reached the end of the stream.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Imprecision in Reader/BufferedReader skip() method Eric Capps Java 1 07-12-2006 09:19 AM
CurrentElement->next = CurrentElement->next->next (UNDEFINED?) Deniz Bahar C Programming 2 03-09-2005 12:45 AM
Why BufferedReader.read(char[], int, int) blocks? vg Java 10 05-07-2004 09:55 AM
BufferedReader InputStreamReader question Robert Java 0 10-05-2003 07:34 PM
Writing something from one thread into BufferedReader of other Thread possible ??? Peter Blatt Java 0 08-11-2003 11:54 AM



Advertisments