重建一个byte数组,长度是前两个数组长度的和,然后遍历前两个数组给新的数组赋新值不就行了。

解决方案 »

  1.   

    byte[] a1 = new byte[4];
    byte[] a2 = new byte[6];
    byte[] a3 = new byte[a1.length + a2.length];
    System.arraycopy(a1, 0, a3 , 0, a1.length);
    System.arraycopy(a2, 0, a3 , a1.length, a3.length);
      

  2.   

    多个马甲就是不一样,api用的就是比俺熟。arraycopy省得遍历了。
      

  3.   

    还有一个方法,构着两个String str1 = String(byte[] bytes1) ;String str2 = String(byte[] bytes2) 
    Byte byte = (str1+str2).getBytes();
      

  4.   

    还是两个for循环速度比较快一些
    byte[] arr = new byte[bys1.length + bys2.length];
    for(int i){}
      

  5.   

    多谢各位了,能不能再问一下把一个String 转换成byte怎么转呢?
    String str="hello";
    byte[] tmp=new byte [str.length()];
    try{
       tmp = str.getBytes("UTF8");
    }catch(Exception e){
    .....
    这样做不对,那要怎样做?