Here you can find the source of longToBytes(long l, byte[] bytes, int offset)
public static void longToBytes(long l, byte[] bytes, int offset)
//package com.java2s; /*// w w w . j a v a 2 s .c o m * JaamSim Discrete Event Simulation * Copyright (C) 2013 Ausenco Engineering Canada Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ public class Main { public static void longToBytes(long l, byte[] bytes, int offset) { bytes[offset + 0] = (byte) ((l & 0xFF00000000000000L) >> 56); bytes[offset + 1] = (byte) ((l & 0x00FF000000000000L) >> 48); bytes[offset + 2] = (byte) ((l & 0x0000FF0000000000L) >> 40); bytes[offset + 3] = (byte) ((l & 0x000000FF00000000L) >> 32); bytes[offset + 4] = (byte) ((l & 0x00000000FF000000L) >> 24); bytes[offset + 5] = (byte) ((l & 0x0000000000FF0000L) >> 16); bytes[offset + 6] = (byte) ((l & 0x000000000000FF00L) >> 8); bytes[offset + 7] = (byte) ((l & 0x00000000000000FFL)); } }