While reading about Java I/O, i realized that there are two ways through which i can write to the standard output.
Following is the snippet that uses both the techn
different of two approach is:
System.out.print("") you actually used a PrintStream instance.Actually the difference is in two classes PrintStream and PrintWriter which are:
PrintStream is a stream of bytes while PrintWrite is a stream of characters.PrintStream uses platform's default encoding while with the PrintWriter you can however pass an OutputStreamWriter with a specific encoding.
for sample:
PrintStream stream = new PrintStream(output);
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, "UTF-8"));You can select a approach with your requirements.