public static byte[] objString2Byte(String value, int max, Charset charset) {
        byte[] fullContentBytes = new byte[max];
        // 填充默认值
        Arrays.fill(fullContentBytes, (byte) 0);
        if (null == value) {
            return fullContentBytes;
        }
        // 获取byte
        byte[] realContent = value.getBytes(charset);
        int length;
        if (realContent.length <= max) {
            length = realContent.length;
        } else {
            length = max;
        }
        // 复制数值
        System.arraycopy(realContent, 0, fullContentBytes, 0, length);
        return fullContentBytes;
    }
public static byte [ ] objString2Byte ( String value , int max , Charset charset ) { byte [ ] fullContentBytes = new byte [ max ] ; Arrays . fill ( fullContentBytes , ( byte ) 0 ) ; if ( null == value ) { return fullContentBytes ; } byte [ ] realContent = value . getBytes ( charset ) ; int length ; if ( realContent . length <= max ) { length = realContent . length ; } else { length = max ; } System . arraycopy ( realContent , 0 , fullContentBytes , 0 , length ) ; return fullContentBytes ; }
将String转换为byte

@return
@throws NoSuchMethodException
@throws InvocationTargetException
@throws IllegalAccessException