我有两个byte数组,里面保存的都是二进制数据,想在需要把这两个数组中的数据分别转换成string和int,请高手指点,谢谢!

解决方案 »

  1.   

    你没说清楚转换算法是什么呀?!比如 byte 数组是这样的,{ 0x31, 0x32, 0x33, 0x34 },那么转换成 string 的话,你是希望得到 "1234" 呢还是 "31323334" 呢?同样,转成 int 你希望是什么样的呢?
      

  2.   

    to maquan :
    如 byte 数组是这样的,{ 0x31, 0x32, 0x33, 0x34 },那么转换成 string 的话,希望得到 "1234" 同样,转成 int 希望得到 "1234"
      

  3.   

    byte[] ba = ....
    String str = new String(ba);
    int n = Integer.parseInt(str);
      

  4.   

    你试试for(int i=0;i<bytes.size;i++)System.out.println((char)bytes[i]);
      

  5.   

    byte[] ba = ....
    String str = new String(ba);
    int n = Integer.parseInt(str);完全正确.