Moving bytes in a Bytebuffer

J

jespersahner

Hi!

I am reading from a ByteBuffer (e.g. of size 10.000 bytes). When a part
of the buffer is read (say 1.000 bytes) I would like to move the
remaining part of the buffer (9.000 bytes), to the start of the buffer
and then fill up the rest of the buffer (from position 9.001 to
10.000).

Which is the easiest way to move the remaining bytes to the start of
the buffer?

Regards,
Jesper
 
R

Remon van Vliet

jespersahner said:
Hi!

I am reading from a ByteBuffer (e.g. of size 10.000 bytes). When a part
of the buffer is read (say 1.000 bytes) I would like to move the
remaining part of the buffer (9.000 bytes), to the start of the buffer
and then fill up the rest of the buffer (from position 9.001 to
10.000).

Which is the easiest way to move the remaining bytes to the start of
the buffer?

Regards,
Jesper

ByteBuffer.compact()

Remon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top