int Byte Array Big Endian - Android File Input Output

Android examples for File Input Output:Byte Array

Description

int Byte Array Big Endian

Demo Code


//package com.book2s;

public class Main {

    public static byte[] int2ByteArrayBigEndian(int num) {
        return int2ByteArray(num);
    }//ww  w.  j a  v  a  2 s  .  c  o m

    public static byte[] int2ByteArray(int num) {
        byte[] b = new byte[4];
        b[0] = (byte) (num >>> 24);
        b[1] = (byte) (num >>> 16);
        b[2] = (byte) (num >>> 8);
        b[3] = (byte) num;
        return b;
    }
}

Related Tutorials