Computer Science Canada preallocate files |
Author: | matt271 [ 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. |
Author: | Vermette [ 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) |