Here you can find the source of toByteArray(short foo)
Parameter | Description |
---|---|
foo | Description of Parameter |
public static byte[] toByteArray(short foo)
//package com.java2s; public class Main { /**/*www.java 2 s .c o m*/ * Description of the Method * * @param foo * Description of Parameter * @return Description of the Returned Value */ public static byte[] toByteArray(short foo) { return toByteArray(foo, new byte[2]); } /** * Description of the Method * * @param foo * Description of Parameter * @return Description of the Returned Value */ public static byte[] toByteArray(int foo) { return toByteArray(foo, new byte[4]); } /** * Description of the Method * * @param foo * Description of Parameter * @return Description of the Returned Value */ public static byte[] toByteArray(long foo) { return toByteArray(foo, new byte[8]); } /** * Description of the Method * * @param foo * Description of Parameter * @param array * Description of Parameter * @return Description of the Return Value * @eturn Description of the Returned Value */ private static byte[] toByteArray(long foo, byte[] array) { int len = array.length; for (int iInd = 0; iInd < len; iInd++) { array[iInd] = (byte) ((foo >> ((len - iInd - 1) * 8)) & 0x000000FF); } return array; } }