console I/O methods in java.lang.System class

The console I/O methods in System class are; read a byte
System.err.print() print a value
System.err.println(); print a value followed by a newline
System.out.print(); print a value
System.out.println(); print a value followed by a newline.
System.setIn(); redirect stdin to a file
System.setErr(); redirect stderr to a file
System.setOut(); redirect stdout to a file


System.setIn(Inputstream in)

 //read a file
 System.setIn(new FileInputStream("E:/hai.txt"));
 //read first character of a file
 char c = (char);
 //print the first character in a file

System.setOut(PrintStream out)

 //create a file
 System.setOut(new PrintStream("E:/hai123.txt"));
 //text gets generated in the file
 System.out.println("This is System class!!!");

Hope this helps you. Please subscribe and comment if you have doubts.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.