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;//  w  ww.  java2 s.co  m
        }
        return bytes;
    }
}

Related

  1. shortToBytes(short number)
  2. shortToBytes(short number)
  3. short2ByteArray(short s)
  4. shortToByte(short number)
  5. shortToBytes(short i)
  6. shorts2bytesBE(short[] val)
  7. shorts2bytesLE(short[] val)
  8. getBytes(short data)
  9. short2bytes(short val)