forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
65 lines
1.4 KiB
6 years ago
|
package com.fanruan.api.util;
|
||
6 years ago
|
|
||
|
import com.fr.stable.os.AbstractOperatingSystem;
|
||
6 years ago
|
import com.fr.stable.os.Arch;
|
||
|
import com.fr.stable.os.OperatingSystem;
|
||
6 years ago
|
|
||
|
/**
|
||
6 years ago
|
* 操作系统判断类,判断操作系统种类
|
||
6 years ago
|
* @author Kalven
|
||
|
* @version 10.0
|
||
|
* Created by Kalven on 2019/8/31
|
||
|
*/
|
||
6 years ago
|
public class OperatingKit {
|
||
6 years ago
|
|
||
6 years ago
|
/**
|
||
|
* 得到当前操作系统信息
|
||
|
*/
|
||
6 years ago
|
private static final AbstractOperatingSystem myOS = com.fr.stable.os.OperatingSystem.getOperatingSystem();
|
||
|
|
||
6 years ago
|
private OperatingKit() {
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取当前机器的操作系统类型
|
||
|
* @return 操作系统类型
|
||
|
*/
|
||
|
public static OperatingSystem getOperatingSystem() {
|
||
|
return myOS.getType();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取当前机器的CPU架构
|
||
|
* @return CPU架构
|
||
|
*/
|
||
|
public static Arch getArch() {
|
||
|
return myOS.getArch();
|
||
6 years ago
|
}
|
||
|
|
||
|
|
||
6 years ago
|
/**
|
||
|
* 判断系统是否是Windows
|
||
|
* @return 判断结果
|
||
|
*/
|
||
6 years ago
|
public static boolean isWindows() {
|
||
|
return myOS.getType() == com.fr.stable.os.OperatingSystem.WINDOWS;
|
||
|
}
|
||
|
|
||
6 years ago
|
/**
|
||
|
* 判断系统是否是Unix
|
||
|
* @return 判断结果
|
||
|
*/
|
||
6 years ago
|
public static boolean isUnix() {
|
||
|
return myOS.isUnix();
|
||
|
}
|
||
|
|
||
6 years ago
|
/**
|
||
|
* 判断系统是否是MacOS
|
||
|
* @return 判断结果
|
||
|
*/
|
||
6 years ago
|
public static boolean isMacOS() {
|
||
|
return myOS.getType() == com.fr.stable.os.OperatingSystem.MACOS;
|
||
|
}
|
||
|
|
||
|
}
|