http://www.35java.com/zhibo/forum.php?mod=viewthread&tid=356&extra=page%3D4
package org.loon.test;
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif) /** *//**
* <p>
* Title: LoonFramework
* </p>
* <p>
* Description:
* </p>
* <p>
* Copyright: Copyright (c) 2007
* </p>
* <p>
* Company: LoonFramework
* </p>
*
* @author chenpeng
* @email:ceponline@yahoo.com.cn
* @version 0.1
*/
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif) public class SystemInfo ...{
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public final static String envStr[] = ...{ "unknown OS type",
"unknown OS version", "unknown OS architecture",
"unknown JRE version", "unknown JRE vendor" };
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) /** *//**
* 遍历所有设置
* @param <K>
* @param <V>
*/
@SuppressWarnings("unchecked")
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public static <K, V> void systemProperties() ...{
Properties p = System.getProperties();
TreeMap<K, V> map = new TreeMap<K, V>();
map.putAll((Map<? extends K, ? extends V>) p);
Iterator itr = map.keySet().iterator();
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) while (itr.hasNext()) ...{
String key = (String) itr.next();
String value = (String) map.get(key);
System.out.println(key + "=" + value);
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) /** *//**
* sun制造标记
* @param type
* @return
*/
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public boolean isSun(String type) ...{
return type.indexOf("Sun") != -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) /** *//**
* applet制造标记
* @param type
* @return
*/
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public boolean isApple(String type) ...{
return type.indexOf("Apple") != -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) /** *//**
* hp制造标记
* @param type
* @return
*/
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public static boolean isHPUX(String type) ...{
return type.indexOf("Hewlett-Packard Company") != -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) /** *//**
* ibm制造标记
* @param type
* @return
*/
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public static boolean isIBM(String type) ...{
return type.indexOf("IBM") != -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) /** *//**
* Blackdown制造标记
* @param type
* @return
*/
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public static boolean isBlackdown(String type) ...{
return type.indexOf("Blackdown") != -1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) /** *//**
* bea制造标记
* @param type
* @return
*/
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public static boolean isBEAWithUnsafeSupport(String type) ...{
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) if (type.indexOf("BEA") != -1) ...{
String vmVersion = System.getProperty("java.vm.version");
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) if (vmVersion.startsWith("R")) ...{
return true;
}
String vmInfo = System.getProperty("java.vm.info");
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) if (vmInfo != null) ...{
return (vmInfo.startsWith("R25.1") || vmInfo
.startsWith("R25.2"));
}
}
return false;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) void getEnv() ...{
// os.name 主机操作系统的名称
// os.version 主机操作系统的版本
// os.arch 主机操作系统的体系结构
// java.version java版本
// java.vendor java厂商
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) String as[] = ...{ "os.name", "os.version", "os.arch", "java.version",
"java.vendor" };
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) for (int i = 0; i < as.length; i++) ...{
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) try ...{
envStr = System.getProperty(as);
System.out.println((as + "=" + ((i==4)?envStr+" "+isSun(envStr):envStr)).intern());
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) } catch (Exception ex) ...{
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif) public static void main(String[] args) ...{
new SystemInfo().getEnv();
System.out.println(" 全部设置 ");
//显示所有设置
systemProperties();
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
}
|