Hello!
In my application I need to create large empty files (>50Mb) then fill them with data.
My problem is that I do not find any method for creating file with a specific size. My current solution is that I create a file something like this (it is just an example code):
conn = (FileConnection) Connector.open( "file:///"+aFilePath,
Connector.READ_WRITE );
conn.create();
Then I open an outputStream to the file and I write empty data to it (just for example a basic code part):
byte[] zeros = new byte[262144];
out = conn.openOutputStream();
// as many times as needed
while(needed){
out.write(zeros);
}
out.flush();
But this solution is very slow if I have to create a large file. Is there any faster way?
Thank you frou your help!
Br,
Peter

Reply With Quote


