Common methods:
The code copy is as follows:
long currentTimeMillis(); Get the millisecond value of the current time
void exit(); terminates the currently running Java virtual machine.
The code copy is as follows:
public static void Method(){
long l = System.currentTimeMillis();
System.out.println(l);
System.exit();
}
Describe 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, that is, a subclass object of the Map collection, it needs to be poured into the util package
Then you can use map method to remove the elements in the set
The keys and values in this set store strings, and there is no generic definition
The code copy is as follows:
public static void Method_Properties(){
//Get all attribute information of the current system
Properties prop = System.getProperties();
//Transfer the attribute information in the prop, you can also use an iterator
for(Object obj: prop.keySet()){
String value = (String)prop.get(obj);
System.out.println(obj+"==="+value);
//Get the corresponding attribute information through key
String value = System.getProperty("os.name");//If this key does not return null
System.out.println(value);
}
}
Customize system information in the system
The code copy is as follows:
public static void SetProperties(){
System.setProperty("makey","myvalue");
System.out.println(System.getProperty("makey"));
}
out: Standard output, default is the monitor
in: Standard input, default is keyboard