📄 sysproperty.java
字号:
package test.property;
import java.util.Enumeration;
/**
* #{System Property Test}
* If you append the argment like "-Dname=wang" to the command "java.exe",
* you will set the system's property named "name" with "wang"
*
* Then , you can get the value of it as follows:
* java.util.Properties property = System.getProperties();
* Object value = propery.get("name");
* @author 王真礼 日期 Jan 21, 2009
*
*/
public class SysProperty {
public static void main(String[] args) {
// SecurityManager sm = System.getSecurityManager();
// System.out.println(sm.getClass());
// System.out.println(SysProperty.class.getClassLoader().getClass().getName());
java.util.Properties pro = System.getProperties();
String name = new String("name");
System.out.println(pro.get(name));
Enumeration<Object> keys = pro.keys();
int i=0;
while (keys.hasMoreElements()) {
Object object = (Object) keys.nextElement();
System.out.println("---- "+i+" -------------------------");
System.out.println("Key:"+object+" \nValue:"+pro.get(object));
i++;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -