Java中System.setProperty()用法
来源:互联网 发布:mac共享设置 编辑:程序博客网 时间:2024/06/15 18:46
转自:http://www.cnblogs.com/chasewade/p/3387390.html
Java中System.setProperty()用法
/*
* 设置指定键对值的系统属性
* setProperty (String prop, String value);
*
* 参数:
* prop - 系统属性的名称。
* value - 系统属性的值。
*
* 返回:
* 系统属性以前的值,如果没有以前的值,则返回 null。
*
* 抛出:
* SecurityException - 如果安全管理器存在并且其 checkPermission 方法不允许设置指定属性。
* NullPointerException - 如果 key 或 value 为 null。
* IllegalArgumentException - 如果 key 为空。
* 注:这里的system,系统指的是 JRE (runtime)system,不是指 OS。
*
*/
//实例
System.setProperty("Property1", "abc");
System.setProperty("Property2","def");
//这样就把第一个参数设置成为系统的全局变量!可以在项目的任何一个地方 通过System.getProperty("变量");来获得,
//System.setProperty 相当于一个静态变量 ,存在内存里面!
public class SystemTest { static { setValue(); } public static void setValue() { System.setProperty("name", "张三"); System.setProperty("age", "28"); } public static void main(String[] args) { System.out.println(System.getProperty("name")); System.out.println(System.getProperty("age")); }}
输出:
阅读全文
0 0
- Java中System.setProperty()用法
- Java中System.setProperty()用法
- Java中System.setProperty()用法
- java中System.setProperty()方法
- java中System.getProperty()和System.setProperty()和System.getProperties()
- 在JAVA中 System.getProperty 和 System.setProperty 方法.
- Java-System Properties, getProperty, setProperty
- System.setProperty(),System.setProperty
- System.setProperty()
- System.setProperty()
- System.setProperty()
- System.setProperty()
- System.setProperty
- System.setProperty
- System.setProperty()
- System.setProperty()
- Java的System.getProperty和System.setProperty()方法
- Java中System的用法
- 分页组件简版
- java基本类型和基本类型包装型比较时的自动拆箱和自动装箱
- android 云标签,文字墙(文字随机排列效果)
- 数组<->指针<->动态数组之间的关系
- redis.clients.jedis.exceptions.JedisClusterException & [ERR] Node 192.168.10.32:7001 is not emp
- Java中System.setProperty()用法
- TCP/IP,HTTP,SOAP等协议之区别
- mongo查询谨记知识点
- freemarker-模板
- 测试道路之第三周
- 每日一题之求二叉树的高度并销毁一棵二叉树
- Portal认证
- A Story of Superior man--The 14th MiniStory of AJ
- js正则表达式的使用: