BufferedReader Method to Read Next Line??

Discussion in 'Java' started by Krmathieu, Dec 25, 2004.

  1. Krmathieu

    Krmathieu Guest

    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
    Krmathieu, Dec 25, 2004
    #1
    1. Advertising

  2. Krmathieu

    Michael Wong Guest

    "Krmathieu" <> wrote in message
    news:...
    > 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.
    Michael Wong, Dec 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vg
    Replies:
    10
    Views:
    9,996
    Andrew Thompson
    May 7, 2004
  2. Hugo
    Replies:
    10
    Views:
    1,299
    Matt Humphrey
    Oct 18, 2004
  3. Eric Capps
    Replies:
    1
    Views:
    880
    Chris Uppal
    Jul 12, 2006
  4. Deniz Bahar
    Replies:
    2
    Views:
    463
    Andrey Tarasevich
    Mar 9, 2005
  5. kaushikshome
    Replies:
    4
    Views:
    759
    kaushikshome
    Sep 10, 2006
Loading...

Share This Page