Android Array Convert convertByteArrayToLongArray(byte[] bytes)

Here you can find the source of convertByteArrayToLongArray(byte[] bytes)

Description

Converts a byte array to a long array.

License

Apache License

Parameter

Parameter Description
bytes a parameter

Declaration

public static long[] convertByteArrayToLongArray(byte[] bytes) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    /**/*w ww.  j  a  v a2 s  .c o m*/
     * Converts a byte array to a long array.
     * @param bytes
     * @return
     */
    public static long[] convertByteArrayToLongArray(byte[] bytes) {
        if (bytes == null)
            return null;

        int count = bytes.length / 8;
        long[] longArray = new long[count];
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        for (int i = 0; i < count; i++) {
            longArray[i] = byteBuffer.getLong();
        }
        return longArray;
    }
}

Related

  1. convertByteArrayToIntArray(byte[] bytes)
  2. convertDoubleArrayToByteArray(double[] doubleArray)
  3. convertDoubleConsonant(byte[] b)