This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

RandomAccessFile and the lost space  RSS feed

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, a RandomAccessFile should reserve space
in advcance, is there a way to solve this problem
or maybe a better solution for my applicartion.
Thx
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi omar, maybe it's just me but your question needs clarification. I'm not sure what you're asking here?
 
omar bili
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, in RandomAccessFile you use the seek method
the file should be full with records from the same
size and you calculate the position of the specified
record, so you must fill the RandomAccessFile with
say 100000 record and then use the seek method to update
the records
hope that my question is more clear
thx
 
author
Posts: 254
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Omar is right--there is no automatic way to "fill" a RandomAccessFile with, say, a million zeroes.

I don't think this is a huge problem. After all, initializing a file isn't a very frequent operation. Simply use the normal file write operations to fill up the file with default records.

Cheers,

Cay
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah ha, I see what you mean. I suppose you would have to create the file using dummy entries, yes, as Cay suggests. I think whether this is viable would therefore rely on how large the file would be (and hence how long it would take to create) and also how often you would need to do this (i.e. is the file initialized every time an application is started, or is it persistent and will only ever need doing once?)
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!