Here you can find the source of extract(ByteBuffer buf)
Parameter | Description |
---|---|
buf | The buffer whose content is to be extracted as defined by the buffer limit. |
static public byte[] extract(ByteBuffer buf)
//package com.java2s; /* Copyright 2012, UCAR/Unidata. See the LICENSE file for more information. */ import java.nio.ByteBuffer; public class Main { /**/*from w w w . ja v a2 s . c o m*/ * Properly extract the byte contents of a ByteBuffer * * @param buf The buffer whose content is to be extracted * as defined by the buffer limit. * @return The byte array contents of the buffer */ static public byte[] extract(ByteBuffer buf) { int len = buf.limit(); byte[] bytes = new byte[len]; buf.rewind(); buf.get(bytes); return bytes; } }