Results 1 to 2 of 2
  1. #1
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Posts
    124
    Rep Power
    0

    Default BufferedReader .mark(int readAheadLimit)

    I've been working on a file management class and would like to establish a permanent mark at the beginning of the file. I've been running into problems with the readAheadLimit. It's easy to go over while traversing the file.

    Does anyone know how to establish a permanent mark at the beginning of the file to return to? I've considered remarking the file during certain method calls but this seems to be wasteful.

    Thanks in advance.

  2. #2
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Posts
    124
    Rep Power
    0

    Default

    Here's one of the constructors for my class:

    Java Code:
       public FileBrowser(File readIt){
          try{
             this.f = readIt;
             this.fr = new FileReader(f);
             this.br = new BufferedReader(fr);
             br.mark((int)f.length() * 10);
          }catch (Exception e){
             System.out.println("Problem creating FileBrowser " + e.toString());
          }  
       }
    The problem is with the mark method. The int passed to it is the number of bytes the BufferedReader can read before it loses the mark. Since I have methods that jump all over the file, the BufferedReader eventually exceeds this number and throws an an exception. Anybody have any experience with this?

Similar Threads

  1. How to use BufferedReader?
    By ProgramBeginner in forum New To Java
    Replies: 4
    Last Post: 10-11-2011, 02:56 PM
  2. Mark thread RESOLVED.
    By Eranga in forum Suggestions & Feedback
    Replies: 45
    Last Post: 04-02-2008, 10:34 AM
  3. Replies: 1
    Last Post: 02-16-2008, 11:22 PM
  4. how to draw an arrow mark using java swing
    By sandhyau in forum AWT / Swing
    Replies: 5
    Last Post: 02-07-2008, 11:52 AM
  5. Help with BufferedReader in java
    By carl in forum New To Java
    Replies: 2
    Last Post: 07-31-2007, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •