Android Byte Array Convert From convertLongArrayToByteArray(long[] longArray)

Here you can find the source of convertLongArrayToByteArray(long[] longArray)

Description

Converts a long array to a byte array.

License

Apache License

Parameter

Parameter Description
longArray a parameter

Declaration

public static byte[] convertLongArrayToByteArray(long[] longArray) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.nio.ByteBuffer;

public class Main {
    /**/*w ww. j a va2s  . com*/
     * Converts a long array to a byte array.
     * @param longArray
     * @return
     */
    public static byte[] convertLongArrayToByteArray(long[] longArray) {
        if (longArray == null)
            return null;
        byte[] bytes = new byte[longArray.length * 8];
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        for (long v : longArray) {
            byteBuffer.putLong(v);
        }
        return bytes;
    }
}

Related

  1. toByteArray(short val, byte[] b, int pos)
  2. toByteArray(short[] array)
  3. toByteArrayFromByteWrapperArray(Byte[] B)
  4. convertIntArrayToByteArray(int[] intArray)
  5. shortToByteArray(short value)
  6. toByte(String value, byte defaultValue)
  7. toByte(int byteValue)
  8. toByte(int n)
  9. toByteObject(String value, Byte defaultValue)