This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Updating a file like table in a database  RSS feed

 
ajay vasudevan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a row is obtained from a text file by StringTokenizer
how can then the fetched row be updated and put into the file again?

like we update a row in a table in a database

please reply with clues...

rgds

ajay vasudevan.
SCJP 1.4
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can be done with RandomAccessFile with some serious restrictions:

You can append data
You can replace old data with new data of exactly the same length
You can't insert
You can't delete

If you have "fixed-length records" you can do some pretty cool stuff, tho. You could build an indexing scheme external to the file or distribute it within the file. With a few thousand hours of spare time you could re-invent mainframe VSAM.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!