Here you can find the source of toBuffer(byte[] arr)
public static ByteBuffer toBuffer(byte[] arr)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static ByteBuffer toBuffer(byte[] arr) { ByteBuffer buffer = ByteBuffer.allocate(arr.length); buffer.put(arr);//from w w w.ja v a 2 s .c om buffer.flip(); return buffer.duplicate(); } }