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  ww .j a  va  2  s .c om

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

Related Tutorials