Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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
Ranch Hand
Posts: 232
27
  • 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?)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!