Android Array Convert convertDoubleArrayToByteArray(double[] doubleArray)

Here you can find the source of convertDoubleArrayToByteArray(double[] doubleArray)

Description

Converts a double array to a byte array.

License

Apache License

Parameter

Parameter Description
doubleArray a parameter

Declaration

public static byte[] convertDoubleArrayToByteArray(double[] doubleArray) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    /**/*from  w  ww. j  av  a  2s.  co m*/
     * Converts a double array to a byte array.
     * @param doubleArray
     * @return
     */
    public static byte[] convertDoubleArrayToByteArray(double[] doubleArray) {
        if (doubleArray == null)
            return null;
        byte[] bytes = new byte[doubleArray.length * 8];
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        for (double v : doubleArray) {
            byteBuffer.putDouble(v);
        }
        return bytes;
    }
}

Related

  1. convertByteArrayToIntArray(byte[] bytes)
  2. convertByteArrayToLongArray(byte[] bytes)
  3. convertDoubleConsonant(byte[] b)