Here you can find the source of getByteArray(ByteBuffer buff)
Parameter | Description |
---|---|
buff | the ByteBuffer to read from |
public static byte[] getByteArray(ByteBuffer buff)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**/*ww w. j ava2 s . c o m*/ * Create a new byte[] array and populate it with the given ByteBuffer's * contents. * * @param buff * the ByteBuffer to read from * @return a new byte array populated from the ByteBuffer */ public static byte[] getByteArray(ByteBuffer buff) { if (buff == null) return null; buff.clear(); byte[] inds = new byte[buff.limit()]; for (int x = 0; x < inds.length; x++) { inds[x] = buff.get(); } return inds; } }