I need a byte buffer class in Java for single-threaded use. I should be able to insert data at the back of the buffer and read data at the front, with an amortized cost of O(1).
Another solution is to use GrowablePipedOutputStream and GrowablePipedInputStream by JBoss.