import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.DoubleBuffer; public class AsDouble { public static void main(String[] args) { File fileName = new File("bharat.txt"); FileOutputStream outStream = null; try { outStream = new FileOutputStream(fileName, true); } catch (FileNotFoundException e) { System.out.println("File not found Error."); } ByteBuffer byteBuf = ByteBuffer.allocate(256); System.out.println("\nInformation related to byte buffer :"); System.out .printf( "ByteBuffer Limit = %4d ByteBuffer position = %2d ByteBuffer capacity = %4d%n", byteBuf.limit(), byteBuf.position(), byteBuf.capacity()); DoubleBuffer charBuf = byteBuf.asDoubleBuffer(); System.out.println("Information related to double buffer :"); System.out .printf( "DoubleBuffer Limit = %4d DoubleBuffer position = %2d DoubleBuffer capacity = %4d%n", charBuf.limit(), charBuf.position(), charBuf.capacity()); try { outStream.close(); } catch (IOException ioe) { System.out.println("IOException is " + ioe); } } }