Convert byte array to double in Java
Description
The following code shows how to convert byte array to double.
Example
/*from w w w .j a va 2s. c om*/
import java.nio.ByteBuffer;
public class Main {
public static double convertToDouble(byte[] array) {
ByteBuffer buffer = ByteBuffer.wrap(array);
return buffer.getDouble();
}
public static void main(String[] argv) {
System.out.println(convertToDouble(new byte[]{67}));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »