qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

Java System类的使用

import java.util.*;
public class SystemTest
{
public static void main(String[] args)
{
//测试arraycopy方法,注意,目的空间必须提前分配
int[] src = {1,2,3,4,5,6,7,8,9};
System.out.println("System.arraycopy");
int[] dst = new int[src.length];
System.arraycopy(src, 0, dst, 0, src.length);
System.out.println("src = "+Arrays.toString(src));
System.out.println("dst = "+Arrays.toString(dst));
//同样是拷贝,Arrays.copyOf方法就不需要手动开辟空间
System.out.println("Arrays.copyOf");
int[] dst1 = Arrays.copyOf(src, src.length);
System.out.println("src = "+Arrays.toString(src));
System.out.println("dst1 = "+Arrays.toString(dst1));
//测试currentTimeMillis()
System.out.println("currentTimeMillis "+System.currentTimeMillis());
//测试nanoTime(),单独输出的结果没有仍和意义,此函数只能用来计算时间差
System.out.println("nanoTime "+System.nanoTime());
long dt=System.nanoTime();
dt = dt - System.nanoTime();
System.out.println("dt = "+dt);
//测试getenv(),注意遍历Map的用法,不是很理解
System.out.println("System.getenv");
Map<String,String> env = System.getenv();
Iterator it = env.entrySet().iterator();
while(it.hasNext())
{
Map.Entry a = (Map.Entry)it.next();
System.out.println("<"+a.getKey()+"> = <"+a.getValue()+">;");
}
//getProperties(),注意遍历Map的用法,不是很理解
System.out.println("System.getProperties");
Properties p = System.getProperties();
p.list(System.out);
System.out.println("Hello World!");
}
}

posted on 2014-04-11 10:32 顺其自然EVO 阅读(186) 评论(0)  编辑  收藏 所属分类: 测试学习专栏


只有注册用户登录后才能发表评论。


网站导航:
 
<2014年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜