Here you can find the source of shortToBytes(short i)
Parameter | Description |
---|---|
i | - The short to convert. |
public static byte[] shortToBytes(short i)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. j av a 2 s .c om * Returns a byte array containing the bytes of the given short in big endian order. * * @param i - The short to convert. * * @return A byte array containing the 2 bytes of the given short in big endian order. */ public static byte[] shortToBytes(short i) { return new byte[] { (byte) (i >> 8), (byte) (i & 0xFF) }; } }