使用Java类System可以获取到大多数系统信息,因此本次判断运行操作系统是否是windows也可以从System类入手。
具体方法:
public boolean isWindows() {
return System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
}
Java判断操作系统
本文介绍了一种使用Java语言来判断当前运行的操作系统是否为Windows的方法。通过调用System类的属性,该方法能够准确地识别出操作系统类型。
使用Java类System可以获取到大多数系统信息,因此本次判断运行操作系统是否是windows也可以从System类入手。
具体方法:
public boolean isWindows() {
return System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
}
2700
1767
778