Here you can find the source of toArray(long l, byte[] b, int offset)
Parameter | Description |
---|---|
l | the long to encode |
b | the array into which the long should be written |
offset | the offset into the array at which the writing should begin |
public static void toArray(long l, byte[] b, int offset)
//package com.java2s; /* // w ww. jav a2 s. c o m Copyright 2004, Martian Software, Inc. 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 { /** * Encodes the specified long in 4 consecutive bytes (big-endian) * in the specified array, beginning at the specified offset. * @param l the long to encode * @param b the array into which the long should be written * @param offset the offset into the array at which the writing * should begin */ public static void toArray(long l, byte[] b, int offset) { b[offset + 3] = (byte) (l % 256); l >>>= 8; b[offset + 2] = (byte) (l % 256); l >>>= 8; b[offset + 1] = (byte) (l % 256); l >>>= 8; b[0] = (byte) (l % 256); } }