欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java ByteBuffer和byte 数组相互转换,bytebufferbyte,// Create a

来源: javaer 分享于  点击 48364 次 点评:61

java ByteBuffer和byte 数组相互转换,bytebufferbyte,// Create a


// Create a byte arraybyte[] bytes = new byte[10];// Wrap a byte array into a bufferByteBuffer buf = ByteBuffer.wrap(bytes);// Retrieve bytes between the position and limit// (see Putting Bytes into a ByteBuffer)bytes = new byte[buf.remaining()];// transfer bytes from this buffer into the given destination arraybuf.get(bytes, 0, bytes.length);// Retrieve all bytes in the bufferbuf.clear();bytes = new byte[buf.capacity()];// transfer bytes from this buffer into the given destination arraybuf.get(bytes, 0, bytes.length);
相关栏目:

用户点评