Here you can find the source of longToLittleEndianBytes(long value, byte[] destination, int offset, int length)
Parameter | Description |
---|---|
value | The long value to be converted to the array of bytes. |
destination | The byte array to where the result is stored. |
offset | The offset in the result array from where the result bytes are stored onwards. |
length | The number of bytes to store the result. |
public static void longToLittleEndianBytes(long value, byte[] destination, int offset, int length)
//package com.java2s; /*/*from w ww . j a va 2s. co m*/ * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: Helper class containing common non-HTI-specific helper * functions that can be used in other java classes. * */ public class Main { /** * Converts a long to the array of bytes in the little endian format. * * @param value The long value to be converted to the * array of bytes. * @param destination The byte array to where the result is stored. * @param offset The offset in the result array from where the * result bytes are stored onwards. * @param length The number of bytes to store the result. */ public static void longToLittleEndianBytes(long value, byte[] destination, int offset, int length) { int shiftBits = 0; for (int i = 0; i < length; i++) { destination[offset + i] = (byte) ((value >> shiftBits) & 0xFF); shiftBits += 8; } } }