Java examples for File Path IO:ByteBuffer
Converting Between a ByteBuffer an a Byte Array
import java.nio.ByteBuffer; public class Main { public static void main(String[] args) { byte[] bytes = new byte[10]; ByteBuffer buf = ByteBuffer.wrap(bytes); bytes = new byte[buf.remaining()]; buf.get(bytes, 0, bytes.length);//from ww w . j av a 2 s . c o m // Retrieve all bytes in the buffer buf.clear(); bytes = new byte[buf.capacity()]; buf.get(bytes, 0, bytes.length); } }