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

posted @ 2017-12-05 18:59  神奇的洋葱  阅读(1690)  评论(0编辑  收藏  举报