Here you can find the source of longToBytes(long value, byte[] array, int offset)
long
as byte
s into the provided array.
Parameter | Description |
---|---|
value | the <code>long</code> to encode |
array | the write target |
offset | the offset in the array at which to write <code>value</code> |
public static void longToBytes(long value, byte[] array, int offset)
//package com.java2s; /****************************************************************************** * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*w ww . j a v a 2s. c o m*/ * Aggregate Knowledge - implementation ******************************************************************************/ public class Main { /** * Writes a <code>long</code> as <code>byte</code>s into the provided array. * @param value the <code>long</code> to encode * @param array the write target * @param offset the offset in the array at which to write <code>value</code> */ public static void longToBytes(long value, byte[] array, int offset) { array[offset + 0] = (byte) (0xff & (value >> 56)); array[offset + 1] = (byte) (0xff & (value >> 48)); array[offset + 2] = (byte) (0xff & (value >> 40)); array[offset + 3] = (byte) (0xff & (value >> 32)); array[offset + 4] = (byte) (0xff & (value >> 24)); array[offset + 5] = (byte) (0xff & (value >> 16)); array[offset + 6] = (byte) (0xff & (value >> 8)); array[offset + 7] = (byte) (0xff & value); } }