aspose file tools*
The moose likes Java in General and the fly likes System.err.println & System.out.println Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "System.err.println & System.out.println" Watch "System.err.println & System.out.println" New topic
Author

System.err.println & System.out.println

Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
Hi guyz,
Seem to me that System.err.println and System.out.println give the same result, printing to the console. What is the different?
Or is it possible to set the output destination of those two method?
Susilo
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi
its all age old OS conventions to have three basic type of streams,
1. standard input (File descriptor: 0)
2. standard output (file descriptior: 1)
3. standard error (file descriptor: 2)
usually, error and output are pointing to the same "physical device" as output that is Screen.
u can try,
this link and following program for demo,

now, to run this.
first try running like,
bash$java ErrOut
you will get out put on the screen,
This should go to Standard Output
This should go to Standard Error
Now, run this like,
bash$java ErrOut 2> TempErrorFile
(OBSERVE THE '>' RIGHT AFTER 2 WHICH IS A STD_ERR descriptor)
you'll get following output on the screen,
This should go to Standard Output
now do,
bash$cat TempErrorFile then u'll see the line,
This should go to Standard Error

well, this is how it works on Unix/Linux. i didnt try with windows.
hope this is helpful.
regards
maulin
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi
forgot to mention
try,
bash$java ErrOut 1> TempFile
then see what u get
regards
maulin
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
Thanks Maulin, that was a great reply.
I've tried the same on Windows and it worked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System.err.println & System.out.println