Here you can find the source of long2ByteLE(byte[] bytes, long value, int offset)
public static void long2ByteLE(byte[] bytes, long value, int offset)
//package com.java2s; /*/*from w w w . j a v a 2 s . co m*/ * Copyright 2015-2017 GenerallyCloud.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static void long2ByteLE(byte[] bytes, long value, int offset) { checkLength(bytes, 8, offset); bytes[offset + 0] = (byte) ((value & 0xff)); bytes[offset + 1] = (byte) ((value >> 8 * 1) & 0xff); bytes[offset + 2] = (byte) ((value >> 8 * 2) & 0xff); bytes[offset + 3] = (byte) ((value >> 8 * 3) & 0xff); bytes[offset + 4] = (byte) ((value >> 8 * 4) & 0xff); bytes[offset + 5] = (byte) ((value >> 8 * 5) & 0xff); bytes[offset + 6] = (byte) ((value >> 8 * 6) & 0xff); bytes[offset + 7] = (byte) ((value >> 8 * 7)); } private static void checkLength(byte[] bytes, int length, int offset) { if (bytes == null) { throw new IllegalArgumentException("null"); } if (offset < 0) { throw new IllegalArgumentException("invalidate offset " + offset); } if (bytes.length - offset < length) { throw new IllegalArgumentException("invalidate length " + bytes.length); } } }