title: What is the best way to store a byte array in memory
body: <p>Somewhere in my server transaction I receive from some backend job a byte array that represents a pdf document.<br>
  Later on in the transaction that pdf needs to be written to a client.
  But at the moment I have that byte array and I want to store it in memory until the pdf file needs to be written to the client.<br>
  What is the best way to deal with a byte array?<br>
  Create a modelobject and keep the byte array there as a plain byte array?<br>
  So for example like this:</p>
  
  <pre><code>public class PdfDocument {
      private byte[] bytearray;
      private String pdftitle;
  }
  </code></pre>
  
  <p>Or is there a better Java Object than just keeping it in memory as a plain byte array?
  Like ByteBuffer or something else.</p>
  
  <p>Thanks</p>