Java Long to Byte Array longToByteArray(long longHi, long longLo, byte[] array, int offset)

Here you can find the source of longToByteArray(long longHi, long longLo, byte[] array, int offset)

Description

long To Byte Array

License

Apache License

Declaration

public static int longToByteArray(long longHi, long longLo, byte[] array, int offset) 

Method Source Code

//package com.java2s;
/*//from  ww w  . ja v  a  2 s  .c o m
 * Copyright 2009 Thomas Bocek
 * 
 * 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 int longToByteArray(long longHi, long longLo, byte[] array, int offset) {
        array[offset++] = (byte) (longHi >>> 56);
        array[offset++] = (byte) (longHi >>> 48);
        array[offset++] = (byte) (longHi >>> 40);
        array[offset++] = (byte) (longHi >>> 32);
        array[offset++] = (byte) (longHi >>> 24);
        array[offset++] = (byte) (longHi >>> 16);
        array[offset++] = (byte) (longHi >>> 8);
        array[offset++] = (byte) longHi;

        array[offset++] = (byte) (longLo >>> 56);
        array[offset++] = (byte) (longLo >>> 48);
        array[offset++] = (byte) (longLo >>> 40);
        array[offset++] = (byte) (longLo >>> 32);
        array[offset++] = (byte) (longLo >>> 24);
        array[offset++] = (byte) (longLo >>> 16);
        array[offset++] = (byte) (longLo >>> 8);
        array[offset++] = (byte) longLo;

        return offset;
    }
}

Related

  1. longToByteArray(long in)
  2. longToByteArray(long input)
  3. longToByteArray(long l)
  4. longToByteArray(long l)
  5. longToByteArray(long l)
  6. longToByteArray(long number)
  7. longToByteArray(long pSrc, byte[] pDst, int pOffset)
  8. longToByteArray(long source)
  9. longToByteArray(long v)