Published: 04 Jan 2018 › Updated: 04 Jan 2018

How to create a ByteBuffer in Java
There are many ways to create a ByteBuffer:
- Create a ByteBuffer using an existing array
byte[] bytes = new byte[BUFFER_SIZE];
ByteBuffer buffer = ByteBuffer.wrap(bytes);
- Create a non-direct ByteBuffer with a specific byte capacity
ByteBuffer buffer = ByteBuffer.allocate(10);
- Create a direct ByteBuffer with a specific byte capacity
ByteBuffer buffer = ByteBuffer.allocateDirect(10);
Please upvote, if you find it useful.
Leave How to create a ByteBuffer in Java to:
Read more #java posts
Best Posts From dayofgameplay
We have not curated any of mirahu's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.