Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 preallocate files
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
matt271




PostPosted: Tue May 05, 2009 12:55 pm   Post subject: preallocate files

in java is it possible to preallocate files?

say i wanna create a file 100mb. so i create the file then "size" it to 100mb. now i can seek to anywhere in the file and write to it.

the only way i can think of to do it, is to write 100mb of garbage and then start witting over top of that. but i dont like this because it has to physically write 100mb to the hard disk.

so if there anyway java can create a 100mb file w/out witting to it? im sure the file system has a way to do it.
Sponsor
Sponsor
Sponsor
sponsor
Vermette




PostPosted: Tue May 05, 2009 2:56 pm   Post subject: RE:preallocate files

try RandomAccessFile.setLength()

http://java.sun.com/j2se/1.5.0/docs/api/java/io/RandomAccessFile.html#setLength(long)
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: