Example of System class

System class contain three final variables called in, out and err.
in: in is a reference variable of type Input Stream and represents always standard keyword.
out and err: out and err are variables of Print Stream which represents always Standard output device called console or monitor.
There are other methods:-currentTimeMillis(), runFinalization(), exit(), gc() and more.
Here see the example of System Class is testSystemClass with some methods


package com.javaforcast;
import java.io.*;
import java.util.*;
public class testSystemClass{


/**
* @Arbind
*/
public static void main(String[] args) {
try {
//System s=new System() because System class constructor is private...
System.out.println("Start");
System.out.println(System.currentTimeMillis());
System.out.println(System.getProperty("os.name"));
System.setProperty("os.name", "Linux");
System.out.println(System.getProperty("os.name"));
System.out.println("---------------------------");
System.setProperty("myname", "Arbind");
Properties p=System.getProperties();
Enumeration e=p.propertyNames();
while(e.hasMoreElements()){
String nm=e.nextElement().toString();
String va=System.getProperty(nm);
System.out.println(nm+"\t:"+va);

}
System.out.println("---------------------------");
System.out.println(System.getProperty("java.library.path"));
System.out.println(System.getProperty("java.class.path"));
System.err.println("This is with err");
System.out.println("This is with out");

File file=new File("arbind123.txt");
file.createNewFile();
OutputStream os=new FileOutputStream(file);
   PrintStream ps=new PrintStream(os);
System.setOut(ps);
System.out.println("Go to file");
System.out.println("Go to file");
System.out.println("Go to file");
System.exit(0);

} catch (IOException e1) {

e1.printStackTrace();
}

}


}