title: Memory Stream in Java
body: <p>I am looking for a memory stream implementation in Java. The implementation
  should be roughly modeled after the <a href="http://msdn.microsoft.com/en-us/library/system.io.memorystream.aspx" rel="noreferrer">.NET memory stream</a> implementation.</p>
  
  <p>Basically I would like to have a class <code>MemoryStream</code> which has to factory
  methods:</p>
  
  <pre><code> class MemoryStream {
       MemoryInput createInput();
       MemoryOutput createOutput();
   }
  
   class MemoryInput extends InputStream {
      long position();
      void seek(long pos);
   }
  
   class MemoryOutput extends OutputStream {
      long position();
      void seek(long pos);
   }
  </code></pre>
  
  <p>So once I have an instance from the class <code>MemoryStream</code> I
  should be able to concurrently simultaneously create
  input and output streams, which should also allow 
  positioning in any direction. The memory stream need
  not be circular, it should work for small sizes well
  and automatically grow. The memory stream need only
  be confined into one process.</p>
  
  <p>Any out of the box code available?</p>