解决方案 »

  1.   

      public byte[] getBytes() {
            return StringCoding.encode(value, 0, value.length);
        }
    String有如上方法直接调用即可。
    “123”.getBytes()
      

  2.   

    你这个方法我知道,你没看我的方法是干什么的,我的方法是把byte[]转换为16进制,然后转换为字符,现在我要反过来.......
      

  3.   

    自己搞定了,看看谁能给优化下?public static byte[] stringtoByte(String str) {
        String tempStr = "";
        byte digest[]=new byte[str.length()/2];    for (int i = 0; i < str.length()/2; i++) {
            tempStr=str.substring(i*2, i*2+2);
            byte b1=(byte)(Integer.valueOf(tempStr, 16) & 0xff);
            digest[i]=b1;
        }
        return digest;
    }