1. Java中Properties类
class="java">
通过key获取value,配置文件常用xxx.properties(属性文件)
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
public class PropertiesTest{
public static void main(String[] args){
Properties p = System.getProperties();
Set set = p.keySet();
for(Iterator iter = set.iterator(); iter.hasNext();){
String key = (String)iter.next();
String value = p.getProperty(key);
System.out.println(key + "=" + value);
}
}
}
运行结果:
……
sun.desktop=windows
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86