---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------
类System
Propertise getPropertise() 获取系统属性信息
Propertise prop = System.getPropertise();
//使用map的方法取出集合中的元素,增强for循环(利用Propertis是Hashtable的子类)
1
2
3
4
5
|
for (Object
obj : prop.keySet()) { String
value = (String)prop.get(obj)l System.out.println(obj+ "--" +value); } |
//在系统中定义一些特有属性
System.setProperty("myKey","myValue");
//获取指定属性信息
String value = System.getProperty("myKey");
------------------------------------------------------------------------------------------------------
类Runtime
使应用程序与系统相关,无构造函数,自有方法返回一个对象static Runtime getRuntime
//获取Runtime对象
Runtime r = Runtime.getRuntime();
//执行本地程序
Pracess p = r.exec("c:\program File\QQ.exe");
//杀掉运行程序的子进程
p.destriy();
------------------------------------------------------------------------------------------------------
类Date、类Calender
//创建时间对象
Date d = new Date();
//创建模板,将模板封装到SimpleDateFormat 对象中
SimpleDateFormat sdf = new SimpleDateFormat(":yyyy年MM月dd日 E hh:mm:ss");
//调用formate方法让模板格式化Date对象
String time = sdf.formate(d);
Calendar c = Calendar.getInstance();
//获取年
String y = c.get(Calendar.YEAR);
//获取月
String M = c.get((Calendar.MONTH)+1)
//查表法获取月
String[] mons = {"一月","二月","三月","四月",.....,"十二月“}:
int index = c.get(Calendar.MONTH);
String M = mons[index];
//设置时间
c.set(2012,2,23);
//设置指定位
c.add(Calendar.MONTH,-1);
------------------------------------------------------------------------------------------------------
Math类
double
double d = 16.34;
double d1 = Math.ceil(d); //返回大于d的最小整数
double d2 = Math.floor(d); //返回小于d的最大整数
double d3 = Math.pow(2,3); //求幂
double d4 = Math.random(); //产生一个[0.0, 1.0);的随机数
int d5 = (int)d4*10; //获得一个[0,10)的随机数
//Random获得一个[0, 10)的随机数
Random r = new Randow();
int d5 = r.nextInt(10);
long l = Math.round(12.34); //四舍五入
---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------