Java ByteBuffer store double type data via DoubleBuffer and read

Description

Java ByteBuffer store double type data via DoubleBuffer and read

import java.nio.ByteBuffer;

public class Main {
   private static final int BSIZE = 1024;

   public static void main(String[] args) {
      ByteBuffer bb = ByteBuffer.allocate(BSIZE);

      bb.rewind();//w  w  w  .  j  a  v  a  2  s. c  o  m
      // Store and read a double:
      bb.asDoubleBuffer().put(123123.123123123D);
      System.out.println(bb.getDouble());

   }
}



PreviousNext

Related