Reputation: 3322
I did search a lot and checked multiple answers.. none of them is clear to me.
Java has ByteBuffer. It has 2 flavors. 1 is direct and the other one is non-direct. The direct buffer is good for IO.
What is the need for non-direct bytebuffer when we have byte[]
? When to use that?
Upvotes: 0
Views: 161
Reputation: 385
non-direct ByteBuffers are stored in the heap and are backed by an underlying byte array. These are typically used when you need a buffer that is readable and writable by the Java application, but doesn't need the same level of performance as a direct ByteBuffer.
So why not always use direct ByteBuffer?
Upvotes: 2