public static String byte2String(byte buf[], int offset)
    {
        int pos = offset;
        for(; offset < buf.length; offset++)
            if(buf[offset] == 0)
                break;

        if(offset > pos)
            offset--;
        else
        if(offset == pos)
            return "";
        int len = (offset - pos) + 1;
        byte bb[] = new byte[len];
        System.arraycopy(buf, pos, bb, 0, len);
        String str = new String(bb);
        return str;
    }