Java ByteBuffer to Double readDouble(ByteBuffer buffer)

Here you can find the source of readDouble(ByteBuffer buffer)

Description

read Double

License

Open Source License

Declaration

public static double readDouble(ByteBuffer buffer) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static double readDouble(ByteBuffer buffer) throws IOException {
        return Double.longBitsToDouble(readLong(buffer));
    }//ww w  . j a va  2 s  .  c  o  m

    public static long readLong(ByteBuffer buffer) throws IOException {
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        long value = buffer.getLong();
        buffer.order(ByteOrder.BIG_ENDIAN);
        return value;
    }
}

Related

  1. readDouble(ByteBuffer buffer)
  2. toDouble(ByteBuffer buffer)
  3. toDouble(ByteBuffer bytes)
  4. toDouble(ByteBuffer value)