/* package IOStreamDemo; import java.io.*; public class IOStreamDemo{ public static void main(String[] args) throws IOException { // TODO code application logic here try { DataOutputStream out2 = new DataOutputStream( new BufferedOutputStream( new FileOutputStream("Data.txt"))); out2.writeDouble(3.14159); out2.writeChars("That was pi\n"); out2.writeBytes("That was pi\n"); out2.close(); FileInputStream in4=new FileInputStream("Data.txt"); DataInputStream in5 =new DataInputStream( new BufferedInputStream( new FileInputStream("Data.txt"))); BufferedReader in5br = new BufferedReader( new InputStreamReader(in5)); //[B]What if I use i4 in constructor????[/B] // Must use DataInputStream for data: System.out.println(in5.readDouble()); // Can now use the "proper" readLine(): System.out.println(in5br.readLine()); // But the line comes out funny. // The one created with writeBytes is OK: System.out.println(in5br.readLine()); } catch(EOFException e) { System.err.println("End of stream"); } } }
I get different outputs, the first one is:
3.14159 T h a t w a s p i That was pi.
the second output with i4 is:
3.14159 @ !щр†n T h a t w a s p i That was pi.
What is the difference?