0

I want to wrap nio.bytebuffer using netty.ByteBuf without making a new object, because I want to slice nio.bytebuffer. But java.nio doesn't have that facility like netty.

4
  • 1
    Java NIO does have a slice operation. What are you talking about? Commented Feb 28, 2016 at 6:30
  • With reflection you do what ever you want. You can even turn a ByteBuf into a ByteBuffer for the same memory, though if you can stick to the public APIs your code will be easier to support. Commented Feb 28, 2016 at 10:05
  • @EJP : agree.but not Returns a slice of this buffer's sub-region.Like natty.slice (netty.io/4.0/api/io/netty/buffer/ByteBuf.html#slice(int,%20int)) Commented Feb 28, 2016 at 10:50
  • @PeterLawrey : yes i can turn ByteBuf to ByteBuffer.. but not ByteBuffer to ByteBuf Commented Feb 28, 2016 at 10:50

1 Answer 1

4

Looks like you want Unpooled.wrappedBuffer(ByteBuffer)

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

2 Comments

@user2004685 - the important part of the link (the name of the relevant method), is included in the post. please remove your downvote.
@jtahlborn I have not down-voted it. Just categorized it as potential link-only answer during one of the reviews, requesting the essential parts of the link to be included in the answer itself.

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.