@Test
public void test(){
String os = System.getProperty("os.name");
if (os != null && os.toLowerCase().startsWith("windows")) {
System.out.println(String.format("当前系统版本是:%s", os));
} else if (os != null && os.toLowerCase().startsWith("linux")) {
System.out.println(String.format("当前系统版本是:%s", os));
} else { //其它操作系统
System.out.println(String.format("当前系统版本是:%s", os));
}
}
结果