Initialisieren unsigned byte-array mit hex-Zahl
Ich weiß, dass unsigned byte fehlt in Java
Dann, wie kann ich die initialisieren, byte-array mit integer aus 0 bis 255 (in hex)?
final byte assoc_resp_msg_int[] = new byte[] {
0xe3, 0x00, //APDU CHOICE Type(AareApdu)
0x00, 0x2c, //CHOICE.length = 44
0x00, 0x00, //result=accept
0x50, 0x79, //data-proto-id = 20601
0x00, 0x26, //data-proto-info length = 38
0x80, 0x00, 0x00, 0x00, //protocolVersion
0x80, 0x00, //encoding rules = MDER
0x80, 0x00, 0x00, 0x00, //nomenclatureVersion
0x00, 0x00, 0x00, 0x00, //functionalUnits, normal Association
0x80, 0x00, 0x00, 0x00, //systemType = sys-type-manager
0x00, 0x08, //system-id length = 8 and value (manufacturer- and device- specific)
0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
0x00, 0x00, //Manager's response to config-id is always 0
0x00, 0x00, //Manager's response to data-req-mode-flags is always 0
0x00, 0x00, //data-req-init-agent-count and data-req-init-manager-count are always 0
0x00, 0x00, 0x00, 0x00, //optionList.count = 0 | optionList.length = 0
};
Unsigned byte ist möglich in Java:
Eclipse richtig zeigt das fehlen des byte-cast, eclipse für den Sieg!
(int)mybyte & 0xFF
finden Sie weitere hierEclipse richtig zeigt das fehlen des byte-cast, eclipse für den Sieg!
InformationsquelleAutor Bear | 2012-02-11
Du musst angemeldet sein, um einen Kommentar abzugeben.
Speichert man
0x80
in byte wie diese :(byte)255
sowieTest:
byte b = (byte) 255; byte c = (byte) 0xFF; if (c == b) System.out.println((b & 0xFF) + " == " + (c & 0xFF));
Vielen Dank für die zusätzlichen Infos 😉
InformationsquelleAutor alain.janinm