Hi Andres,
Yep, there's another way, and I'll admit I was hoping you'd ask ;-). Take a look at the ByteBuffer.duplicate() method: > Creates a new byte buffer that shares this buffer's content. > > The content of the new buffer will be that of this buffer. Changes > to this buffer's content will be visible in the new buffer, and > vice versa; the two buffers' position, limit, and mark values will > be independent. > > The new buffer's capacity, limit, position, and mark values will > be identical to those of this buffer. You can create a second ByteBuffer "view" on the same in-memory data, use one to your reads and the other to do your writes. They both start at the same position and they both have the same limit, so if you read from one and write to the other within the loop body, they stay in sync. At the end of the loop, rewind the source buffer and discard the duplicate. Barend On Thu, Oct 2, 2008 at 10:34 PM, Andres Quijano <[EMAIL PROTECTED]> wrote: > I don't like to read and then have to rewind the position like this... > is there another way? I couldn't find a peek method or something that > reads without modifying the position
