Here you can find the source of intToShortBytes(int a)
Parameter | Description |
---|---|
a | int value |
public static byte[] intToShortBytes(int a)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w . jav a 2 s .c o m*/ * Convert an int value to a 2-byte array. * @param a int value * @return byte[2] array */ public static byte[] intToShortBytes(int a) { byte[] returnByteArray = new byte[2]; //short is 2 bytes returnByteArray[0] = (byte) ((a & 0x0000ff00) >> 8); returnByteArray[1] = (byte) ((a & 0x000000ff)); return returnByteArray; } }