Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Returning to a checkpoint in a file  RSS feed

 
Phil Cornthwaite
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have a batch program that will potentially read a million lines from a file. I can take a checkpoint from it very easily by getting the lin number from the LineNumberReader i am using. I need to know if there is any easy way to jump to that line when the program falls over, and I need to return to my previous checkpoint? The only way I have so far is to readLine() from the reader until the line number = the checkpoint. Surely Java has an easier way to do this???
If so, could anyone PLEASE enlighten me? I am desperate to get this program running now!
Thanks,
Phil.
 
Ryan Langley
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
One possible alternative could be to use the RandomAccessFile Class. I'm not sure what your program totally entails, but you could save the position that you want to use as a checkpoint, and later when you wanted to return there, all you would have to do is use the seek() method and pass it the position integer. Hoep this will help you figure it out!

------------------
Cheers,
RL
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!