Java可读取操作系统的配置

时间:2024-09-11 16:06:02
 /**
* Java获取操作系统的配置环境
* @throws Exception
*/
@Test
public void testPro() throws Exception {
Properties properties = System.getProperties();
for(Entry<Object, Object> entry:properties.entrySet()){
System.out.println(entry.getKey()+"============="+entry.getValue());
} //获取从根目录到项目名的路径
String path = System.getProperty("user.dir");
System.out.println(path);
}