admin管理员组

文章数量:1794759

java 中byte[] 数组的合并 //System.arraycopy()方法 public static byte[] byteMerger(byte[] bt1, byte[]

代码语言:javascript代码运行次数:0运行复制
    //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;  
    } 

代码语言:javascript代码运行次数:0运行复制
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);
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2024-12-16,如有侵权请联系 cloudcommunity@tencent 删除staticsystem数组javabyte

本文标签: java 中byte 数组的合并Systemarraycopy()方法 public static byte byteMerger(byte bt1byte