<code
class
=
"hljs cs"
>
import
java.util.Properties;
public
class
SystemDemo {
public
static
void
main(String[] args){
Properties pro = System.getProperties();
//獲取所有屬性信息
for
(Object obj:pro.keySet()){
String value = (String) pro.get(obj);
System.out.println(value);
}
//獲取制定屬性信息
String value = System.getProperty(
"os.name"
);
System.out.println(value);
//自定義屬性信息
System.setProperty(
"football"
,
"good"
);
System.out.println(System.getProperty(
"football"
));
//在jvm啟動時(shí),,動態(tài)加載屬性信息。
//待續(xù)……
}
}
</code>