title: How to initialize a ByteBuffer if you don't know how many bytes to allocate beforehand?
body: <p>Is this:</p>
  
  <pre><code>ByteBuffer buf = ByteBuffer.allocate(1000);
  </code></pre>
  
  <p>...the only way to initialize a <code>ByteBuffer</code>?</p>
  
  <p>What if I have no idea how many bytes I need to allocate..?</p>
  
  <p><strong>Edit:</strong> More details:</p>
  
  <p>I'm converting one image file format to a TIFF file. The problem is the starting file format can be any size, but I need to write the data in the TIFF to little endian. So I'm reading the stuff I'm eventually going to print to the TIFF file into the ByteBuffer first so I can put everything in Little Endian, then I'm going to write it to the outfile. I guess since I know how long IFDs are, headers are, and I can probably figure out how many bytes in each image plane, I can just use multiple ByteBuffers during this whole process.</p>