BufferedWriter flush方法

BufferedWriter br = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream(file)), 40960);
char[] str = new char[40959];
for (int i = 0 ; i < 40959; i++) {
str[i] = 'a';
}
long time = System.currentTimeMillis();
br.write(str);
System.out.println(System.currentTimeMillis() - time);
time = System.currentTimeMillis();
br.flush();
System.out.println(System.currentTimeMillis() - time);



输出:

    0
    2

原文地址:https://www.cnblogs.com/younghome/p/7988823.html