Java Utililty Methods Short to Byte Array

List of utility methods to do Short to Byte Array

Description

The list of methods to do Short to Byte Array are organized into topic(s).

Method

byte[]fromShort(int shortValue)
Interpret a short as its binary form
byte[] bytes = new byte[2];
bytes[0] = (byte) (shortValue >> 8);
bytes[1] = (byte) ((shortValue << 8) >> 8);
return bytes;
byte[]fromShort(short input)
Returns a byte array containing 2 network byte ordered bytes representing the given short .
byte[] output = new byte[2];
output[0] = (byte) (input >> 8);
output[1] = (byte) input;
return output;
byte[]fromShort(short key)
from Short
byte[] writeBuffer = new byte[2];
writeBuffer[0] = (byte) ((key >>> 8) & 0xFF);
writeBuffer[1] = (byte) key;
return writeBuffer;
byte[]fromShort(short number)
from Short
return new byte[] { (byte) (number >> 8), (byte) (number & 255) };
byte[]fromShort(short value)
Converts a short value to a byte array.
byte[] result = { (byte) (0xFF & (value >>> 8)), (byte) (0xFF & value) };
return result;