Android Short to Byte Array Convert shortToByte(short number)

Here you can find the source of shortToByte(short number)

Description

short To Byte

Declaration

public static byte[] shortToByte(short number) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] shortToByte(short number) {
        int temp = number;
        byte[] b = new byte[2];
        for (int i = (b.length - 1); i >= 0; i--) {
            b[i] = new Integer(temp & 0xff).byteValue();
            temp = temp >> 8;/*w ww. j a  v  a 2 s. co  m*/
        }
        return b;
    }
}

Related

  1. shortToBytes(short number)
  2. shortToBytes(short number)
  3. short2ByteArray(short s)
  4. shortToBytes(short i)
  5. shortToBytes(short number)
  6. shorts2bytesBE(short[] val)
  7. shorts2bytesLE(short[] val)