This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference in "println" statements...  RSS feed

 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between the "system.out.println" and "system.err.println" statements?

Why is the "system.err.println" statement used when displaying the error message obtained from an exception?

I know that there is a reason, I'm just curious what it is.

Thanks,

Landon
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API documentation for System.err...
...By convention, this output stream is used to display error messages or other information that should come to the immediate attention of a user even if the principal output stream, the value of the variable out, has been redirected to a file or other destination that is typically not continuously monitored.

Does that help?
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Landon Blake,

You will find your answer in this thread..

System class and available methods

regards,
[ August 08, 2006: Message edited by: saif uddin ]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
most operating systems i am aware of have two output streams - standard out and standard error. usually, both go to the screen.

however, sometimes, you may want to separate where they go. say you're running a script or program that produces some output. you want to save the output to a file. but you also want to know when you encounter a bad record. however, you don't want to mix your error messages with your good data.

you can print your data to the .out, and direct it to one file, and your error messages to .err and direct it to a different file.
 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This makes perfect sense. I want to thank all responders for taking the time to explain the difference.

Landon
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!