那是目标结果数组长度出错
给你一个public class BytesAdd {
public static byte[] bytesAddWay(byte[] buf1,byte[] buf2) {
byte[] bufret=null;
int len1=0;
int len2=0; if(buf1!=null)
len1=buf1.length;
if(buf2!=null)
len2=buf2.length;
if(len1+len2>0)
bufret=new byte[len1+len2];
if(len1>0)
System.arraycopy(buf1,0,bufret,0,len1);
if(len2>0)
System.arraycopy(buf2,0,bufret,len1,len2);//bufret like is (buf1+buf2) return bufret;
}
}
给你一个public class BytesAdd {
public static byte[] bytesAddWay(byte[] buf1,byte[] buf2) {
byte[] bufret=null;
int len1=0;
int len2=0; if(buf1!=null)
len1=buf1.length;
if(buf2!=null)
len2=buf2.length;
if(len1+len2>0)
bufret=new byte[len1+len2];
if(len1>0)
System.arraycopy(buf1,0,bufret,0,len1);
if(len2>0)
System.arraycopy(buf2,0,bufret,len1,len2);//bufret like is (buf1+buf2) return bufret;
}
}
即所有byte[] 替换看看
我没注意这个
原理上都一样啊