• Post Reply Bookmark Topic Watch Topic
  • New Topic

accessing opened file

 
nan sud
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello

I am writing a header record and large number of data records and a trailor record. I would get the count of data records only after I finished writing the data records. The problem is I need to put this count in the hearder itself. How can we do this?
I don't want to re-open the file and write the count in the header record, after closing it as it consists of huge data and also I don't want to pre-process to get the count before i write.

thanks for your help .
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use java.io.RandomAccessFile; when you know the actual number of records, rewind the file back to the header and write it over again with the correct numbers.
 
nan sud
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. that helped
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!