Byte array with padding of null bytes at the end: how to efficiently copy to smaller byte array

前端 未结 4 497
独厮守ぢ
独厮守ぢ 2020-12-28 16:17

Have:

[46][111][36][11][101][55][87][30][122][75][66][32][49][55][67][77][88][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]

4条回答
  •  长情又很酷
    2020-12-28 16:20

    I think we can do in this way also

    byte []array={0, 69, 0, 71, 0, 72};
    
    byte ar[]=new String(array).replaceAll("\0", "").getBytes();
    

提交回复
热议问题