Ratu
Ratu

Reputation: 29

What determines where a System.out.println(args) command prints to?

It may be a silly question but I can't find anything on the web with the answer. What (if anything) determines where the args of a System.out.println(args) command will be displayed? I've been using an IO class created by my lecturer which created it's own GUI and wrote to specific areas of that by default but now that I am making my own programs I am struggling to get the text/images/whatever to display where I want it to.

Upvotes: 1

Views: 91

Answers (2)

morgano
morgano

Reputation: 17422

Depending on the operating system you're using, each process has associated a standard input, standard output and a standard error. If you execute your program in a console, the it will be your standard input, output and error.

For instance, in Linux you can redirect the standard output with redirection operators like this:

java MyClass > fileAsOutput.txt

Upvotes: 0

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272557

From the Javadocs for System.out:

The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.

In most computing environments, there are three standard streams associated with a process.

Note, however, that System.out can be reassigned in Java, by using System.setOut().

Upvotes: 4

Related Questions