File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes how setIn() and setOut() works. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how setIn() and setOut() works." Watch "how setIn() and setOut() works." New topic

how setIn() and setOut() works.

Sumant Mehta

Joined: Jan 09, 2014
Posts: 10
in system class in & out methods are static final data member which means there value can not be change after intialization, if its true then how setIn() and setOut() works.
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
Sumant Mehta wrote:how setIn() and setOut() works.

If you look at the source code for the System class (there's a in your JDK installation), you will see that those methods actually call native code, so how it works is operating system dependent.
Luan Cestari
Ranch Hand

Joined: Feb 07, 2010
Posts: 163

A good question. I remeber that I had that question long ago. I found the answer looking the source code like the following:

As you can see, the class statically call the registerNatives which is native and also have some other internal native methods to make the things works (even that not follow the Java language rules (due it is native))


Please, visit me for some cool tech post at
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
Welcome to the Ranch
I agree. Here's the link:
subject: how setIn() and setOut() works.
jQuery in Action, 3rd edition