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

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?

asked Jun 5 by dtivl (2,500 points)

1 Answer

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.

answered Jun 5 by dtivl (2,500 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...