First, the Java.lang.System class.
This class contains some useful class fields and methods. It cannot be instantiated.
In the System
facilities provided by the class, there are standard input, standard output and error output streams, access to externally defined properties and environment variables, methods for loading files and libraries, and a practical way to quickly copy part of an array.
1. Currenttimemillis method.
The method returns the millisecond value of the current system time.
long currenttime=system.currenttimemillis (); System.out.println (currenttime); // gets the millisecond value of the current time to midnight 1970.1.1.
2. Key methods: GetProperties, GetProperty and SetProperty methods.
getProperties () |
GetProperty (String key) |
GetProperty (String key,string def) |
setproperties (Properties props) |
The first three methods are the methods used to get the system properties, the method to get all the properties, the second method and the third method are the methods to get a system property based on key.
The fourth method is to add the specified system attributes (key-value pairs) to the system property set.
Properties is a subclass of Hashtable, so it also holds key-value pairs. But it doesn't have generics, and it has its own way of traversing:
Gets the set set of keys by using the Stringpropertyname () method.
The value is obtained by the GetProperty method based on the key.
String |
getProperty(String key) Searches for a property in this property list with the specified key. |
String |
getProperty(String key, String defaultValue) Searches for a property in the property list with the specified key. |
"Java Common class demo"