title: How to set the buffer size on a BufferedWriter over a FileWriter
body: <p>I met a problem with <code>BufferedWriter</code> when I write data to a single file with some threads.</p>
  
  <p>I set the buffer size of the <code>BufferedWriter</code>, but no matter what number I set, it flushes the data to disk when the buffer is 8192 (the default buffer size), not the size I set (here is 16384). Is there a problem with my code? </p>
  
  <p>This is how I'm constructing the <code>BufferedWriter</code>:</p>
  
  <pre><code>new BufferedWriter(new FileWriter(fileName, true), 16384);
  </code></pre>
  
  <p>This is the full code:</p>
  
  <pre><code>import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  
  public class Test1 {
      public static void main(String[] args) throws IOException {
          for(int i =0;i&lt;10;i++){
              MyThread r = new MyThread();
              Thread t = new Thread(r);
              t.start();
          }
      }
  }
  
  class MyThread implements Runnable {
      public void run() {
          String s = "{addffffffkkkljlkj2015dd}\n";
          BufferedWriter bw = null;
          try {
              bw = new BufferedWriter(new FileWriter(
                      "/Users/liaoliuqing/Downloads/1.txt", true),16384);
          } catch (IOException e) {
              e.printStackTrace();
          }
          for(int i =0 ; i&lt;1000; i++){
              try {
                  bw.write(String.format("%03d", i)+s);
                  //bw.flush();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>