Java Byte Array Create toBytes(short s)

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

Description

to Bytes

License

LGPL

Declaration

public static byte[] toBytes(short s) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static byte[] toBytes(short s) {
        return new byte[] { (byte) (s & 0x00FF), (byte) ((s & 0xFF00) >> 8) };
    }/*  w  w w  .  j ava 2  s. com*/
}

Related

  1. toBytes(long value)
  2. toBytes(long value, int numBytes)
  3. toBytes(long... values)
  4. toBytes(Object objValue)
  5. toBytes(Object value)
  6. toBytes(short s)
  7. toBytes(short sVal, byte[] bytes, boolean bigEndian)
  8. toBytes(short value)
  9. toBytes(short value)