Here you can find the source of toShort(byte[] input)
Parameter | Description |
---|---|
input | A network byte-ordered representation of an short . |
public static short toShort(byte[] input)
//package com.java2s; //License from project: BSD License public class Main { /**//from ww w .java 2 s .co m * Converts a given byte array to an {@code short}. Bytes are expected in * network byte * order. * * @param input A network byte-ordered representation of an {@code short}. * @return The {@code short} value represented by the input array. */ public static short toShort(byte[] input) { assert input.length == 2 : "toShort(): Byte array length must be 2."; short output = 0; output = (short) (((input[0] & 0xff) << 8) | (input[1] & 0xff)); return output; } }