java.lang.System.setProperties()%uA0方法设置系统属性的属性参数。
声明
以下是java.lang.System.setProperties()方法的声明
public static void setProperties(Properties props)
参数
-
props%uA0-- 这是新的系统属性。
返回值
此方法不返回任何值。
异常
-
SecurityException%uA0--%uA0如果安全管理器存在并且其checkPropertiesAccess方法不允许访问系统属性。
例子
下面的例子显示java.lang.System.setProperties()方法的使用。
package com.yiibai import java.lang.* public class SystemDemo { public static void main(String[] args) { // prints Java Runtime Version before property set System.out.print("Previous : ") System.out.println(System.getProperty("java.runtime.version")) Properties p = System.getProperties() p.put("java.runtime.version", "Java Runtime 1.6.0") System.setProperties(p) // prints Java Runtime Version after property set System.out.print("New : ") System.out.println(System.getProperty("java.runtime.version")) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Previous : 1.6.0_22-b22 New : Java Runtime 1.6.0