Common methods:
Copy Code code as follows:
Long Currenttimemillis (); Gets the millisecond value of the current time
void exit () terminates the currently running Java virtual machine.
Copy Code code as follows:
public static void Method () {
Long L = System.currenttimemillis ();
System.out.println (l);
System.exit ();
}
Describes system attribute information: Properties System.getproperties ();
The information obtained by this method is stored in the Properties collection
Because properties is a subclass of Hashtable, a subclass of the map collection, pour into the util package
Then you can retrieve the elements of the collection by using the Map method
The keys and values in the collection are stored in strings, no generic definitions
Copy Code code as follows:
public static void Method_properties () {
Get all property information for the current system
Properties prop = System.getproperties ();
Iterate through the property information in the prop, or you can use an iterator
For (Object Obj:prop.keySet ()) {
String value = (string) prop.get (obj);
System.out.println (obj+ "= = =" +value);
Get the corresponding property information by key
String value = System.getproperty ("Os.name");//If no this key returns null
System.out.println (value);
}
}
Customizing system information in the system
Copy Code code as follows:
public static void SetProperties () {
System.setproperty ("Makey", "myvalue");
System.out.println (System.getproperty ("Makey"));
}
Out: Standard output, default is monitor
In: standard input, default is keyboard