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.
-
1Java NIO does have a slice operation. What are you talking about?user207421– user2074212016-02-28 06:30:51 +00:00Commented 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.Peter Lawrey– Peter Lawrey2016-02-28 10:05:58 +00:00Commented 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))amil shanaka– amil shanaka2016-02-28 10:50:12 +00:00Commented Feb 28, 2016 at 10:50
-
@PeterLawrey : yes i can turn ByteBuf to ByteBuffer.. but not ByteBuffer to ByteBufamil shanaka– amil shanaka2016-02-28 10:50:17 +00:00Commented Feb 28, 2016 at 10:50
Add a comment
|
1 Answer
Looks like you want Unpooled.wrappedBuffer(ByteBuffer)
2 Comments
jtahlborn
@user2004685 - the important part of the link (the name of the relevant method), is included in the post. please remove your downvote.
ninja.coder
@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.