title: Buffer size in Java
body: <p>I have got a little question about buffer size in Java. Why do we set buffer size to <code>1024</code> or <code>2^n</code>. For example:</p>
  
  <pre><code>    inputStream = file.getInputStream();
      File newFile = new File("C:/uploads/operators.xml");
      outputStream = new FileOutputStream(newFile);
      int read = 0;
  
      byte[] bytes = new byte[1024];
      while ((read = inputStream.read(bytes)) != -1) {
          outputStream.write(bytes, 0, read);
      }
      outputStream.close();
      inputStream.close();
  </code></pre>
  
  <p>How <code>outputStream.write(bytes, 0, read);</code> works? Why do we use <code>bytes</code> array?</p>