Android Short to Byte Array Convert short2ByteArray(short s)

Here you can find the source of short2ByteArray(short s)

Description

short Byte Array

Declaration

public static byte[] short2ByteArray(short s) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] short2ByteArray(short s) {
        byte[] shortBuf = new byte[2];
        for (int i = 0; i < 2; i++) {
            int offset = (shortBuf.length - 1 - i) * 8;
            shortBuf[i] = (byte) ((s >>> offset) & 0xff);
        }//from ww w .j a va  2 s . com
        return shortBuf;
    }
}

Related

  1. shortToBytes(short number)
  2. shortToBytes(short number)
  3. shortToByte(short number)
  4. shortToBytes(short i)
  5. shortToBytes(short number)
  6. shorts2bytesBE(short[] val)