Java Reference
In-Depth Information
The above example copies the entire contents of the buffer's array and converts
that copy into a
String
. Another method of the
String
class that can be very useful
when processing data within a
ByteBuffer
does the opposite of the above. Method
getBytes
converts a specifi ed
String
into an array of bytes, which may then be writ-
ten to the buffer.
Example
String myStringData = "Just an example";
byte[] byteData = myStringData.getBytes();
buffer.put(byteData);
Search WWH ::
Custom Search