byte数组按16进制的方式输出
public class test {
public static void main(String[] args) {
byte[] stackByte = new byte[]{0x02, 0x06, 0x00, 0x01, 0x00, 0x01, 0x19, (byte) 0xF9};
String h = "";
for (int i = 0; i < stackByte.length; i++) {
String temp = Integer.toHexString(stackByte[i] & 0xFF);
if (temp.length() == 1) {
temp = "0" + temp;
}
h = h + " " + temp;
}
System.out.println(h);
}
}