JAvaにおけるbyte arrayとshortタイプの相互変換
284 ワード
public static void putShort(byte b[], short s) {
b[1] = (byte) (s >> 8);
b[0] = (byte) (s >> 0);
}
public static short getShort(byte[] b) {
return (short) (((b[1] << 8) | b[0] & 0xff));
}