//System.arraycopy()方法 public static byte[] byteMerger(byte[] bt1, byte[] bt2){ byte[] bt3 = new byte[bt1.length+bt2.length]; System.arraycopy(bt1, 0, bt3, 0, bt1.length); System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length); return bt3; }
byte[] recvDataHead = {2,48,48,48,50,48,48,48,48,48,48,3}; byte[] recvData = DataPackage.buildPkg(cmdh, cmdl, param, param_offset, param_len); int length=recvDataHead.length+recvData.length; byte[] recvDataFin = new byte[length]; //数组头部添加头部信息;进行数组合并。 System.arraycopy(recvDataHead, 0, recvDataFin, 0, recvDataHead.length); System.arraycopy(recvData, 0, recvDataFin, recvDataHead.length, recvData.length); hostMessage.setResponseMsg(recvDataFin);