Here you can find the source of toBytes(long v, byte[] writeBuffer, int o)
public static byte[] toBytes(long v, byte[] writeBuffer, int o)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] toBytes(long v, byte[] writeBuffer, int o) { writeBuffer[o + 0] = (byte) (v >>> 56); writeBuffer[o + 1] = (byte) (v >>> 48); writeBuffer[o + 2] = (byte) (v >>> 40); writeBuffer[o + 3] = (byte) (v >>> 32); writeBuffer[o + 4] = (byte) (v >>> 24); writeBuffer[o + 5] = (byte) (v >>> 16); writeBuffer[o + 6] = (byte) (v >>> 8); writeBuffer[o + 7] = (byte) (v >>> 0); return writeBuffer; }/*from w w w . j ava 2 s . c o m*/ public static byte[] toBytes(long v, byte[] writeBuffer) { return toBytes(v, writeBuffer, 0); } public static byte[] toBytes(long v) { byte[] writeBuffer = new byte[8]; return toBytes(v, writeBuffer, 0); } public static byte[] toBytes(long[] v, byte[] writeBuffer, int o) { for (int i = 0; i < v.length; i++) toBytes(v[i], writeBuffer, o + i * 8); return writeBuffer; } public static byte[] toBytes(long[] v) { byte[] writeBuffer = new byte[8 * v.length]; return toBytes(v, writeBuffer, 0); } public static byte[] toBytes(int v, byte[] writeBuffer, int o) { writeBuffer[o + 0] = (byte) (v >>> 24); writeBuffer[o + 1] = (byte) (v >>> 16); writeBuffer[o + 2] = (byte) (v >>> 8); writeBuffer[o + 3] = (byte) (v >>> 0); return writeBuffer; } public static byte[] toBytes(int v) { byte[] writeBuffer = new byte[4]; return toBytes(v, writeBuffer, 0); } public static byte[] toBytes(int[] v, byte[] writeBuffer, int o) { for (int i = 0; i < v.length; i++) toBytes(v[i], writeBuffer, o + i * 4); return writeBuffer; } public static byte[] toBytes(int[] v) { byte[] writeBuffer = new byte[4 * v.length]; return toBytes(v, writeBuffer, 0); } public static byte[] toBytes(short v, byte[] writeBuffer, int o) { writeBuffer[o + 0] = (byte) (v >>> 8); writeBuffer[o + 1] = (byte) (v >>> 0); return writeBuffer; } public static byte[] toBytes(short v) { byte[] writeBuffer = new byte[2]; return toBytes(v, writeBuffer, 0); } public static byte[] toBytes(short[] v, byte[] writeBuffer, int o) { for (int i = 0; i < v.length; i++) toBytes(v[i], writeBuffer, o + i * 2); return writeBuffer; } public static byte[] toBytes(short[] v) { byte[] writeBuffer = new byte[2 * v.length]; return toBytes(v, writeBuffer, 0); } }