writeDouble(double): This method is available in the java.io.DataOutputStream class of Java.
Syntax:
void java.io.DataOutputStream.writeDouble(double v) throws IOException
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.
Note: If no exception is thrown, the counter written is incremented by 8.
Parameters: One parameter is required for this method.
v: a double value to be written.
Returns: NA
Throws:
IOException - if an I/O error occurs.
Approach
Java
import java.io.DataOutputStream;import java.io.FileOutputStream;import java.io.IOException;public class DataOutputStreamwriteDouble {public static void main(String[] args) throws IOException {FileOutputStream file =new FileOutputStream("D:\\hello.txt");DataOutputStream data = new DataOutputStream(file);double v = 1001.9191;data.writeDouble(v);System.out.println("Successfully writes");data.close();}}
Output:
Successfully writes
No comments:
Post a Comment