to Big Endian Dword - Java Internationalization

Java examples for Internationalization:Charset

Description

to Big Endian Dword

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(toBigEndianDword(value)));
    }/*from  ww w. j  av a  2s  .c o m*/

    public static byte[] toBigEndianDword(final long value) {
        return new byte[] { (byte) ((value & 0xFF000000L) >>> 24),
                (byte) ((value & 0x00FF0000L) >>> 16),
                (byte) ((value & 0x0000FF00L) >>> 8),
                (byte) (value & 0x000000FFL) };
    }
}

Related Tutorials