import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
/**
* <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
*/
public class SystemInfo {
public final static String envStr
[] = { "unknown OS type",
"unknown OS version", "unknown OS architecture",
"unknown JRE version", "unknown JRE vendor" };
/**
* 遍历所有设置
*
* @param <K>
* @param <V>
*/
@SuppressWarnings("unchecked")
public static <K, V> void systemProperties() {
TreeMap<K, V> map = new TreeMap<K, V>();
map.putAll((Map<? extends K, ? extends V>) p);
while (itr.hasNext()) {
System.
out.
println(key
+ "=" + value
);
}
}
/**
* sun制造标记
*
* @param type
* @return
*/
public boolean isSun
(String type
) {
return type.indexOf("Sun") != -1;
}
/**
* applet制造标记
*
* @param type
* @return
*/
public boolean isApple
(String type
) {
return type.indexOf("Apple") != -1;
}
/**
* hp制造标记
*
* @param type
* @return
*/
public static boolean isHPUX
(String type
) {
return type.indexOf("Hewlett-Packard Company") != -1;
}
/**
* ibm制造标记
*
* @param type
* @return
*/
public static boolean isIBM
(String type
) {
return type.indexOf("IBM") != -1;
}
/**
* Blackdown制造标记
*
* @param type
* @return
*/
public static boolean isBlackdown
(String type
) {
return type.indexOf("Blackdown") != -1;
}
/**
* bea制造标记
*
* @param type
* @return
*/
public static boolean isBEAWithUnsafeSupport
(String type
) {
if (type.indexOf("BEA") != -1) {
if (vmVersion.startsWith("R")) {
return true;
}
if (vmInfo != null) {
return (vmInfo.startsWith("R25.1") || vmInfo
.startsWith("R25.2"));
}
}
return false;
}
void getEnv() {
// os.name 主机操作系统的名称
// os.version 主机操作系统的版本
// os.arch 主机操作系统的体系结构
// java.version java版本
// java.vendor java厂商
String as
[] = { "os.name",
"os.version",
"os.arch",
"java.version",
"java.vendor" };
for (int i = 0; i < as.length; i++) {
try {
envStr
[i
] = System.
getProperty(as
[i
]);
System.
out.
println((as
[i
] + "=" + ((i
== 4) ? envStr
[i
] + " "
+ isSun(envStr[i]) : envStr[i])).intern());
}
}
}
public static void main
(String[] args
) {
new SystemInfo().getEnv();
// 显示所有设置
systemProperties();
}
}