读取JAVA系统属性

其实读取 JAVA系统的属性 很简单。通过 System.getProperty() 方法可以了。
比如,对于 user.home 属性,可以用 System.getProperty("user.home") 
对于 java.home 属性,可以用 System.getProperty("java.home")  ;
实例1
public class Test {
static ArrayList <String> list;
/**
 * @param args
 */
public static void main(String[] args) {
System.out.println("user.home:"+System.getProperty("user.home") );
System.out.println("java.home:"+System.getProperty("java.home") );
}
}
结果
user.home :C:\Documents and Settings\hubin
java.home :C:\Program Files\Java\jre6
另外我们可以 System.getProperties().propertyNames() 方法得到JAVA系统所有属性的名字,然后接着通过 System.getProperty() 方法就能 遍历 JAVA系统所有属性值了。

你可能感兴趣的:(java,c,String,Class)