DataInputStream ReadDouble() Example

returns the next eight bytes of this input stream, interpreted as a double.


DataInputStreamclass ReadDouble() method example. This example shows you how to use ReadDouble() method.This method returns the next eight bytes of this input stream, interpreted as a double.

Here is the code:-

/**
 * @Program that returns the next eight bytes of this input stream, interpreted
as a double.
 * ReadDouble.java 
 * Author:-RoseIndia Team
 * Date:-07-jun-2008
 */
import java.io.*;

public class ReadDouble {

    public static void main(String[] argsthrows IOException {
        double dD = 23.45;
        FileOutputStream fos = new FileOutputStream("Linux.txt");
        DataOutputStream dos = new DataOutputStream(fos);
        dos.writeDouble(dD);
        dos.flush();
        dos.close();
        FileInputStream fis = new FileInputStream("Linux.txt");
        DataInputStream dis = new DataInputStream(fis);
        //returns the next two bytes of this input stream, interpreted 
        //as a double. 
        double d = dis.readDouble();
        System.out.println("The next eight bytes of this input stream is :" + d);
    }
}

Output of the Program
 The next eight bytes of this input stream is :23.45

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US