jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes To where is standard output being written? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "To where is standard output being written?" Watch "To where is standard output being written?" New topic
Author

To where is standard output being written?

d jones
Ranch Hand

Joined: Mar 13, 2006
Posts: 76
Is it possible to determine where java is writing its standard output?

If we start a program with "java testProgram > logfile.log"

Is it possible to identify in the program that it is writing its standard output to a file called logfile.log?

Many Thanks
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
No, not with Pure Java anyway. The redirection is being done by the operating system, so Java does not know about it.

If it was really, really important to you, it might be possible to find out, using either native code (JNI) or external processes (Runtime.exec()). Neither approach is portable or attractive.

Why do you want this information?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
 
subject: To where is standard output being written?
 
Similar Threads
Difference b/w System.out.println and err.println
get Output of a main method call
Printing unicode character
java code on as a output
Closing the DOS window?