在字节数组java的末尾添加一个空格或“0”

时间:2013-04-09 09:00:29

标签: java bytearray

如何以这样的方式修改现有的字节数组如果条件符合我可以附加“空格”或“0”

for example :: 
last 2 byte Hex value if E0 in decimal is -32 
   byte1 [] = [48, 16, 6, 11, 43, 6, 1, 2, 1, 69, 1, 2, 1, 6, 9, 4, 1, -32]
last 1byte 101=e 48=0
    byte2[]=[48, 17, 6, 11, 43, 6, 1, 2, 1, 69, 1, 2, 1, 6, 9, 4, 2, 101, 48]

我怎么知道在字节数组中最后一个索引是否为2字节本身或1字节,如果这是十六进制那么我需要在字节数组上添加“0”或“空格”

In precise : the last character need to be checked 
byte b = byte1[18]
check this whether it's one byte or 2 byte if it come as "e0" then 2 byte if it's come as "0" then modify the byte array to contain extra "0"

0 个答案:

没有答案