Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-16-2007, 09:16 PM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 123
Rep Power: 0
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-16-2007, 10:58 PM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 123
Rep Power: 0
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
Default
Here's one of the constructors for my class:

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?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mark thread RESOLVED. Eranga Suggestions & Feedback 45 04-02-2008 10:34 AM
how u rotate the arrow mark as the line moves accordingly sandhyau AWT / Swing 1 02-16-2008 11:22 PM
how to draw an arrow mark using java swing sandhyau AWT / Swing 5 02-07-2008 11:52 AM
How to use BufferedReader? ProgramBeginner New To Java 2 11-04-2007 09:08 AM
Help with BufferedReader in java carl New To Java 2 07-31-2007 07:20 AM


All times are GMT +2. The time now is 02:52 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org