// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class BigEndianAgain2 {
    public static byte[] toBigEndian(int i) {
        byte[] bbig = new byte[4];
        bbig[0] = (byte) ((i >> 24) & 0xFF);
        bbig[1] = (byte) ((i >> 16) & 0xFF);
        bbig[2] = (byte) ((i >> 8) & 0xFF);
        bbig[3] = (byte) (i & 0xFF);
        return bbig;
    }
    public static void main(String[] args) {
        byte[] ba = toBigEndian(117);
        for(byte b : ba) {
            System.out.print(" " + (b & 0xFF));
        }
        System.out.println();
    }
}
