Use of System.err instead of System.out in printing error messages
Post by:ramya narayanan
, Ranch Hand
Dear all, I want to know what is the use of System.err instead of System.out in printing error messages? Any specific reason or just because it is a good practice we're using it? Regards.
Post by:fred rosenberger
a lot of the time, you want to separate your regular output from your error output.
Say your program is processing a million records, and generating output that will be fed to another program. some of the records will fail. You don't want 20k lines of good data, a bunch of error messages, then 30k more good data, then more error messages...
if you separate your standard out from your error out, you can generate a file with all the good data, and feed it straight into your next program. You can then check your error file for the records that failed, and decide how to handle those later.