to Big Endian Word - Java Internationalization

Java examples for Internationalization:Charset

Description

to Big Endian Word

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        long value = 2;
        System.out.println(java.util.Arrays
                .toString(toBigEndianWord(value)));
    }/*from  w  w w . ja v a  2  s .c o m*/

    public static byte[] toBigEndianWord(final long value) {
        return new byte[] { (byte) ((value & 0xFF00L) >>> 8),
                (byte) (value & 0xFF) };
    }
}

Related Tutorials