PrintStream v/s PrintWriter
807597Jul 5 2005 — edited Jul 8 2005In the folloowing code, I have used PrintStream to output some text to a file.
package src;
import java.io.*;
public class Sample {
public static void main(String[] args) {
PrintStream out = null;
try{
out = new PrintStream("c:\\jay.txt");
}
catch(Exception e){
e.printStackTrace();
}
out.println("This is test");
out.close();
}
}
If, instead I use PrintWriter class instance in place of PrintStream, I get the same result. The resultant file is of the same size and displays the same text. Here I have got confused... I want to confess that I have no clue why this is happening... I thought PrintStream puts characters in 8-bit format and PrintWriter in 16-bit format... How come the editor I use to open the file interpret both the formats...