Android Short to Byte Array Convert shortToBytes(short number)

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

Description

short To Bytes

Declaration

public static byte[] shortToBytes(short number) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] shortToBytes(short number) {
        int temp = number;
        byte[] bytes = new byte[2];
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = new Integer(temp & 0xff).byteValue();
            temp = temp >> 8;//from www . j a  v  a 2 s .  co  m
        }
        return bytes;
    }
}

Related

  1. shortToBytes(short number)
  2. short2ByteArray(short s)
  3. shortToByte(short number)
  4. shortToBytes(short i)
  5. shortToBytes(short number)