jsp中如何输出操作系统的相关信息呢?
下文笔者讲述jsp中列举出操作系统的相关信息的简介说明,如下所示
实现思路:
借助Runtime.getRuntime()中的相关方法
即可打印出当前服务器的信息
例:
void printSystemInfo(JspWriter out)throws Exception{
try{pro.destroy();}catch(Exception e){}
Map map=null;
Set set=null;
Iterator it=null;
map=System.getProperties();
set=map.keySet();
it=set.iterator();
out.println("<hr>系统属性:<ul>");
while(it.hasNext()){
Object oName=it.next();
out.println("<li>"+oName+" [ "+map.get(oName)+" ]");
}
out.print("</ul><hr>CPU :");
out.print(Runtime.getRuntime().availableProcessors()+" <br>");
out.print("空闲内存:"+getSize(Runtime.getRuntime().freeMemory()));
out.print("<br>总内存 :"+getSize(Runtime.getRuntime().maxMemory()));
}
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


