首页>代码>spring boot集成sigar极简入门实例>/springboot-sigar/src/main/java/com/simon/springbootsigar/sigar/OsCheck.java
package com.simon.springbootsigar.sigar;
/**
* @author Simon
*/
public class OsCheck {
public enum OSType {
Windows, MacOS, Linux, Other
}
protected static OSType detectedOS;
public static OSType getOperatingSystemType() {
if (detectedOS == null) {
String OS = System.getProperty("os.name", "generic").toLowerCase();
if (OS.indexOf("win") >= 0) {
detectedOS = OSType.Windows;
} else if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) {
detectedOS = OSType.MacOS;
} else if (OS.indexOf("nux") >= 0) {
detectedOS = OSType.Linux;
} else {
detectedOS = OSType.Other;
}
}
return detectedOS;
}
}

最近下载
最近浏览