4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

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.

10 upvotes 4 downvotes $0.12

Replies (3)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: