Java Byte Array Create toBytesShortBE(short w)

Here you can find the source of toBytesShortBE(short w)

Description

to Bytes Short BE

License

Open Source License

Declaration

public static byte[] toBytesShortBE(short w) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] toBytesShortBE(short w) {
        byte[] ret = new byte[2];
        writeShortBE(ret, 0, w);/*w  w  w  .ja  v a 2s . co m*/
        return ret;
    }

    public static void writeShortBE(byte[] target, int offset, short w) {
        target[offset] = (byte) ((w >> 8) & 0xFF); // most significant byte first
        target[offset + 1] = (byte) (w & 0xFF); // least significant byte next
    }
}

Related

  1. toBytesFromUnicode(String s)
  2. toBytesHexEscaped(final byte[] s, final int off, final int len)
  3. toBytesInt32BE(int w)
  4. toBytesLittleEndian(long value, int cnt)
  5. toBytesOctalEscaped(final byte[] s, final int off, final int len)
  6. toBytesString(byte[] bytes)
  7. toByteString(byte[] bytes, String seperator)
  8. toByteString(byte[] content, int len)
  9. toByteString(final byte[] b)