Here you can find the source of bytesToShort(byte hiByte, byte loByte)
Parameter | Description |
---|---|
hiByte | the high byte |
loByte | the low byte |
public static final short bytesToShort(byte hiByte, byte loByte)
//package com.java2s; /**//from w w w. j a va 2 s. co m * Portions Copyright 2001 Sun Microsystems, Inc. * Portions Copyright 1999-2001 Language Technologies Institute, * Carnegie Mellon University. * All Rights Reserved. Use is subject to license terms. * * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL * WARRANTIES. */ public class Main { /** Reconstructs a short from its hi and low bytes. * @param hiByte the high byte * @param loByte the low byte * @return the short value */ public static final short bytesToShort(byte hiByte, byte loByte) { int result = (0x000000FF & hiByte); result = result << 8; result |= (0x000000FF & loByte); return (short) result; } }