Answer the question
In order to leave comments, you need to log in
Why does BufferedWriter write slower than FileWriter?
I need to measure the performance of buffered and unbuffered writes to a file and compare them. I wrote this code:
String text = "ABCDEF";
long startTime, stopTime;
BufferedWriter w = new BufferedWriter(new FileWriter("file1.txt"));
startTime = System.nanoTime();
w.write(text);
w.close();
stopTime = System.nanoTime();
print(stopTime - startTime); // 1
FileWriter w1 = new FileWriter("file1.txt");
startTime = System.nanoTime();
w1.write(text);
w1.close();
stopTime = System.nanoTime();
print(stopTime - startTime); // 2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question