I need to create large test files—near 3 GB. So I try to write for start only string “1”—to check performance and correctness.
FileWriter fstream = new FileWriter("c:/out.txt");
BufferedWriter out = new BufferedWriter(fstream,10000000);
for (int i = 0; i < 1000000000; i++) {
//out.write(Integer.toString(1));
out.write("1");
out.newLine();
}
out.close();
In future versions I need to write random integers. Now it takes on my computer 3 min 26 s.
Changing size of buffere seems doesn’t help.
Is it possible to accelerate process of writing? Thanks.
Well, 3GB is 3072MB – and if you have a writing speed of 25MBps – it should take a bit longer then 2 minutes. Try it on a different computer and compare results – maybe its just you hard drive that isn’t fast