I have this program to write into a file. I have a problem with my PrintStream
public static void main(String[] args) throws Exception { int i; DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("e:\\My Ebooks\\rahulverma.txt"))); out.writeBytes("Hello Rahul Verma1 \n"); out.writeDouble(93.6); PrintStream printer = new PrintStream("e:\\My Ebooks\\rahulverma.txt"); //Using another outputstream object to write to the file double val = 93.6; printer.print(val); out.close(); printer.close(); DataInputStream input = new DataInputStream(new BufferedInputStream(new FileInputStream("e:\\my ebooks\\rahulverma.txt"))); String str = input.readLine(); //Pardon the deprecated method! double value = input.readDouble(); System.out.println(str+"........"+value); input.close(); }
I am not getting the value 93.6 in the human readable format in my file. I just cant get the problem.
Please help!