Java Utililty Methods Short Number Create

List of utility methods to do Short Number Create

Description

The list of methods to do Short Number Create are organized into topic(s).

Method

short[]toShort(byte[] src)
Convert an array of byte 's into an array of short '.
int number = src.length;
short[] dst = new short[number];
for (int j = 0; j < number; ++j) {
    dst[j] = (short) src[j];
return dst;
shorttoShort(byte[] value)
byte[] -> short
if (value == null || value.length != 2) {
    return 0x0;
return (short) ((0xff & value[0]) << 8 | (0xff & value[1]) << 0);
shorttoShort(char[] bytes, boolean le)
to Short
if (bytes.length != 4)
    return 0;
return (short) Long.parseLong(bytesToString(bytes, le, true), 16);
shorttoShort(final byte[] b)
Build a short from first 2 bytes of the array.
return (short) ((b[1] & 0xFF) + ((b[0] & 0xFF) << 8));
shorttoShort(final byte[] b)
Converts the bytes in an array into the corresponding short value.
return toShort(b, 0);
shorttoShort(final byte[] buffer, final int offset, final int length)
to Short
short ret = 0;
final int done = offset + length;
for (int i = offset; i < done; i++) {
    ret = (short) (((ret << 8) & 0xffff) + (buffer[i] & 0xff));
return ret;
shorttoShort(final byte[] inputBytes, int offset)
Form a short value reading 2 bytes
return (short) ((inputBytes[offset] << 8) + (inputBytes[++offset] & 0xff));
shorttoShort(final String bitString)
Convert a bit string into a short value.
assert (bitString.length() <= Short.SIZE);
return (short) toLong(bitString);
ShorttoShort(final String value)
create Intger from str.
return Short.parseShort(value);
shorttoShort(int src)
to Short
return (short) (src & 0xFFFF);