DataOutputStream WriteDouble() Example

Converts the double argument to a long using the doubleToLongBits method


DataOutputStreamclass WriteDouble() method example. This example shows you how to use WriteDouble() method.This method Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first.

Here is the code:-
/**
 * @Program that Converts the double argument to a long using the doubleToLongB
    its method in class Double, and then writes that long value to the 
    underlying output stream
 * WriteDouble.java 
 * Author:-RoseIndia Team
 * Date:-09-jun-2008
 */
import java.io.*;
public class WriteDouble {
public static void main(String[] args)throws IOException {
double d=234;
FileOutputStream fos=new FileOutputStream("g.txt");    
DataOutputStream dos=new DataOutputStream(fos);
//Converts the double argument to a long using the doubleToLongB
dos.writeDouble(d);
FileInputStream fis=new FileInputStream("g.txt");    
DataInputStream dis=new DataInputStream(fis);
System.out.println("Double to the underlying output stream is : "+dis.readDouble());
    }

}

Output of the Program
 Double to the underlying output stream is : 234.0

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

HOME | COPYRIGHT | CONTACT US