代码:
public static boolean isWindows() {
return System.getProperty("os.name").toUpperCase().indexOf("WINDOWS")>=0?true:false;
}
扩展:System 中有很多的属性
public static Properties getProperties()
Determines the current system properties.
First, if there is a security manager, its checkPropertiesAccess
method is called with no arguments. This may result in a security exception.
The current set of system properties for use by the getProperty(String) method is returned as a Properties
object. If there is no current set of system properties, a set of system properties is first created and initialized. This set of system properties always includes values for the following keys:
Key | Description of Associated Value |
| Java Runtime Environment version |
| Java Runtime Environment vendor |
| Java vendor URL |
| Java installation directory |
| Java Virtual Machine specification version |
| Java Virtual Machine specification vendor |
| Java Virtual Machine specification name |
| Java Virtual Machine implementation version |
| Java Virtual Machine implementation vendor |
| Java Virtual Machine implementation name |
| Java Runtime Environment specification version |
| Java Runtime Environment specification vendor |
| Java Runtime Environment specification name |
| Java class format version number |
| Java class path |
| List of paths to search when loading libraries |
| Default temp file path |
| Name of JIT compiler to use |
| Path of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release. |
| Operating system name |
| Operating system architecture |
| Operating system version |
| File separator ("/" on UNIX) |
| Path separator (":" on UNIX) |
| Line separator ("\n" on UNIX) |
| User's account name |
| User's home directory |
| User's current working directory |
其中有一个os.name 可以获取当当前使用操作系统的
希望对你有所帮助