• Post Reply Bookmark Topic Watch Topic
  • New Topic

Restart in a RandomAccessFile  RSS feed

Steve Deringer
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been looking at the posts in the I/O forum and think I've got the basics of an answer, but wanted to walk this thru with someone.

I have to take an existing program that has a property file and input file & process the input file run thru some complex logic. As I process the records in the file (fields that are strings or date delimited by |), I create a backout file which is of the same format - but contains the object I'm modifying BEFORE the update takes place.

I have to be able to do 2 things regarding backout/restore - and not deviate from the format(s) above:
a) Scenario A: User wants us to restart from a restart point in the file (there are certain records that would make sense to restart from)
b) Scenario B: Catastrophe. Don't restart the program. Just backout everything you did from the Backout File.

For Scenario A, I was going to make the input file be RandomAccessFile - looks like using the getFilePointer() will return a long which I can record somewhere (there will be a lag in time for deciding whether to restore or backout) so I can restart later....I wanted to write this pointer to the Properties File (which I also have) so that I could read it as a property - I already also use a Property File (plain File and FileInputStream).
I was looking at this post as a way to do this, but not sure this will work: http://www.coderanch.com/t/274836/Streams/java/help-writing-file

QUESTION : Will this (the post) work for what I have planned? Can I just define a FileOutputStream for the property file and append a 'long' variable to it? Or is there a better way?

Thanks in advance - and sorry if this is posted somewhere and i did not see it. I tried to do a diligent job of researching b4 the post.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!