1. 程式人生 > >mina 使用IoBuffer獲取byte[]

mina 使用IoBuffer獲取byte[]

    /**
     * 獲取IoBuffer len長度資料
     * @param buf
     * @param len 長度
     * @return byte[]
     */
    public static byte[] IoBuffertoBytes(IoBuffer buf,int len){
        byte[] b = new byte[len];
        buf.get(b);
        return b;
    }

//byte[]轉String   

new String(byte[])