Here you can find the source of convertDoubleArrayToByteArray(double[] doubleArray)
Parameter | Description |
---|---|
doubleArray | a parameter |
public static byte[] convertDoubleArrayToByteArray(double[] doubleArray)
//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; } }