-1
ByteBuffer[] output = new ByteBuffer[256];
socketChannel.read(output);

android. i want to get bytes array from ByteBuffers. not ByteBuffer

2 Answers 2

0

Depends what you want to do.

If what you want is to retrieve the bytes that are remaining (between position and limit), then what you have will work. You could also just do:

ByteBuffer bb =..

byte[] b = new byte[bb.remaining()] bb.get(b); which is equivalent as per the ByteBuffer javadocs.

Reference from Jason S (Gets byte array from a ByteBuffer in java)

Sign up to request clarification or add additional context in comments.

Comments

0
ByteBuffer[] output = new ByteBuffer[256];
ByteBuffer output = ByteBuffer.allocate(256);

its different. output.get no works with my code

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.