Quantcast
Channel: Examples Java Code Geeks » ByteBuffer
Browsing all 7 articles
Browse latest View live

Convert between ByteBuffer and byte array

// Create a byte array byte[] bytes = new byte[10]; // Wrap a byte array into a buffer ByteBuffer buf = ByteBuffer.wrap(bytes); // Retrieve bytes between the position and limit // (see Putting Bytes...

View Article



Create direct and non-direct ByteBuffer

In this example we are going to demonstrate several methods of creating a direct (memory-mapped) and non-direct ByteBuffer in Java. Given a direct byte buffer, the Java virtual machine will make a best...

View Article

Put byte into ByteBuffer

This is an example of how to put bytes into a ByteBuffer in Java. Additionally we will demonstrate several of ByteBuffer‘s API methods in order to share some light on how to randomly write data to it....

View Article

Get byte from ByteBuffer

With this example we are going to demonstrate how to read bytes from a ByteBuffer. Additionally we will show you several of ByteBuffer‘s API methods in order to share some light on how to randomly...

View Article

Use ByteBuffer to store Strings

This is an example of how to store Strings using a ByteBuffer in Java. In order to use a ByteBuffer to store Strings in Java we have to : Allocate a new ByteBuffer and set its size to a number large...

View Article


Use ByteBuffer for non-byte Java types buffering

In this example we will demonstrate how to perform non-byte Java types buffering using a ByteBuffer in Java. In particular we are going to show you how to use a ByteBuffer to store the following Java...

View Article

Write/Append to File with ByteBuffer

With this is example we are going to demonstrate how to write/append data to a file in Java using a ByteBuffer. Particularly we are going to read data from a source file and append them to the...

View Article
Browsing all 7 articles
Browse latest View live




Latest Images