title: what is the fastest way to write a byte array to socket outputstream in java
body: <p>As the title, and assume the size of byte array is no larger than 16 Kbytes.</p>
  
  <p>Currently I am implementing a middleware for MySQL (like MySQL Proxy), which requires high throughput. but the overhead caused by reading data from socket and writing data to socket. For now, I use </p>
  
  <pre><code>in = new DataInputStream(new BufferedInputStream(socket.getInputStream()))
  </code></pre>
  
  <p>and </p>
  
  <pre><code>out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()))
  </code></pre>
  
  <p>When read data and write, I use</p>
  
  <p><code>in.read(byte[] b)</code> and <code>out.write(byte[] b, int offset, int len)</code> with <code>out.flush()</code></p>
  
  <p>Can anyone tell me a better way to do this?</p>