How to print a line to STDERR and STDOUT in Java?

Posted on In QA

In Java, how to print a string as a line to STDOUT? That is, the string and the newline character, nicely?

And similarly, how to print the line to STDERR?

In Java, you can print string in a new line by ‘System.out.println()’ to STDOUT:

System.out.println("my msg here");

In Java, print a string str to STDERR as a new line:

System.err.println(str)

Standard error cab be accessed with ‘System.err’ in Java.

Leave a Reply

Your email address will not be published. Required fields are marked *