title: What's a good resizable, random access, efficient byte vector class in Java?
body: <p>I'm trying to find a class for storing a vector of bytes in Java, which supports: random access (so I can get or set a byte anywhere), resizing (so I can either append stuff to the end or else manually change the size), reasonable efficiency (I might be storing megabytes of data in these things), all in memory (I don't have a file system). Any suggestions?</p>
  
  <p>So far the candidates are:</p>
  
  <ul>
  <li><code>byte[]</code>. Not resizable.</li>
  <li><code>java.util.Vector&lt;Byte&gt;</code>. Evil. Also painfully inefficient.</li>
  <li><code>java.io.ByteArrayOutputStream</code>. Not random-access.</li>
  <li><code>java.nio.ByteBuffer</code>. Not resizable.</li>
  <li><code>org.apache.commons.collections.primitives.ArrayByteList</code>. Not resizable. Which is weird, because it'll automatically resize if you add stuff to it, you just can't change the size explicitly!</li>
  <li>pure RAM implementation of <code>java.nio.channels.FileChannel</code>. Can't find one. (Remember I don't have a file system.)</li>
  <li>Apache Commons VFS and the RAM filesystem. If I must I will, but I really like something lighter weight...</li>
  </ul>
  
  <p>This seems like such an odd omission that I'm sure I <em>must</em> have missed something somewhere. I just figure out what. What am I missing?</p>