Here you can find the source of toBigEndianByteArray(long val, byte[] b, int pos)
public static void toBigEndianByteArray(long val, byte[] b, int pos)
//package com.java2s; public class Main { public static void toBigEndianByteArray(int val, byte[] b, int pos) { assert (pos + 4 <= b.length); for (int i = 3; i >= 0; i--) { b[pos + i] = (byte) (val & 0x000000FF); val = val >> 8; }/*from w w w.j a v a 2 s . c om*/ } public static void toBigEndianByteArray(short val, byte[] b, int pos) { assert (pos + 2 <= b.length); b[pos + 1] = (byte) (val & 0x00FF); b[pos] = (byte) ((val & 0xFF00) >> 8); } public static void toBigEndianByteArray(long val, byte[] b, int pos) { assert (pos + 8 <= b.length); for (int i = 7; i >= 0; i--) { b[pos + i] = (byte) (val & 0x00000000000000FFl); val = val >> 8; } } }