strTemp.getBytes(),得到的就是字节数组。

解决方案 »

  1.   

    jintaos (happyhappy) 你的目的是要是转成byte数组,可以用楼上的
    public byte[] getBytes()
    Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.   还有:public char[] toCharArray()
            Converts this string to a new character array.
      

  2.   

    谢谢大家,搞定了,要在字符后加个\n才能正常转换
    将String strTemp="13628728123"转换得到一数组
    strTemp=strTemp+"\n";
    byte src_addr[] = new byte[12];
    src_addr=strTemp.getBytes();才能得到
    src_addr[0] = 0x31;
    src_addr[1] = 0x33;
    src_addr[2] = 0x36;
    src_addr[3] = 0x32;
    src_addr[4] = 0x38;
    src_addr[5] = 0x37;
    src_addr[6] = 0x32;
    src_addr[7] = 0x38;
    src_addr[8] = 0x31;
    src_addr[9] = 0x32;
    src_addr[10]= 0x33;
    src_addr[11]= 0x0;