| | |
| | | package com.zy.asrs.common.properties; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/1 |
| | | */ |
| | | public class OSinfo { |
| | | |
| | | private static final String OS = System.getProperty("os.name").toLowerCase(); |
| | | |
| | | private static final OSinfo _instance = new OSinfo(); |
| | | |
| | | private SysOsType sysOsType; |
| | | |
| | | private OSinfo(){} |
| | | |
| | | public static boolean isLinux(){ |
| | | return OS.contains("linux"); |
| | | } |
| | | |
| | | public static boolean isMacOS(){ |
| | | return OS.contains("mac") &&OS.indexOf("os")>0&& !OS.contains("x"); |
| | | } |
| | | |
| | | public static boolean isMacOSX(){ |
| | | return OS.contains("mac") &&OS.indexOf("os")>0&&OS.indexOf("x")>0; |
| | | } |
| | | |
| | | public static boolean isWindows(){ |
| | | return OS.contains("windows"); |
| | | } |
| | | |
| | | public static boolean isOS2(){ |
| | | return OS.contains("os/2"); |
| | | } |
| | | |
| | | public static boolean isSolaris(){ |
| | | return OS.contains("solaris"); |
| | | } |
| | | |
| | | public static boolean isSunOS(){ |
| | | return OS.contains("sunos"); |
| | | } |
| | | |
| | | public static boolean isMPEiX(){ |
| | | return OS.contains("mpe/ix"); |
| | | } |
| | | |
| | | public static boolean isHPUX(){ |
| | | return OS.contains("hp-ux"); |
| | | } |
| | | |
| | | public static boolean isAix(){ |
| | | return OS.contains("aix"); |
| | | } |
| | | |
| | | public static boolean isOS390(){ |
| | | return OS.contains("os/390"); |
| | | } |
| | | |
| | | public static boolean isFreeBSD(){ |
| | | return OS.contains("freebsd"); |
| | | } |
| | | |
| | | public static boolean isIrix(){ |
| | | return OS.contains("irix"); |
| | | } |
| | | |
| | | public static boolean isDigitalUnix(){ |
| | | return OS.contains("digital") &&OS.indexOf("unix")>0; |
| | | } |
| | | |
| | | public static boolean isNetWare(){ |
| | | return OS.contains("netware"); |
| | | } |
| | | |
| | | public static boolean isOSF1(){ |
| | | return OS.contains("osf1"); |
| | | } |
| | | |
| | | public static boolean isOpenVMS(){ |
| | | return OS.contains("openvms"); |
| | | } |
| | | |
| | | /** |
| | | * 获取操作系统名字 |
| | | * @return 操作系统名 |
| | | */ |
| | | public static SysOsType getOSname(){ |
| | | if(isAix()){ |
| | | _instance.sysOsType = SysOsType.AIX; |
| | | }else if (isDigitalUnix()) { |
| | | _instance.sysOsType = SysOsType.Digital_Unix; |
| | | }else if (isFreeBSD()) { |
| | | _instance.sysOsType = SysOsType.FreeBSD; |
| | | }else if (isHPUX()) { |
| | | _instance.sysOsType = SysOsType.HP_UX; |
| | | }else if (isIrix()) { |
| | | _instance.sysOsType = SysOsType.Irix; |
| | | }else if (isLinux()) { |
| | | _instance.sysOsType = SysOsType.Linux; |
| | | }else if (isMacOS()) { |
| | | _instance.sysOsType = SysOsType.Mac_OS; |
| | | }else if (isMacOSX()) { |
| | | _instance.sysOsType = SysOsType.Mac_OS_X; |
| | | }else if (isMPEiX()) { |
| | | _instance.sysOsType = SysOsType.MPEiX; |
| | | }else if (isNetWare()) { |
| | | _instance.sysOsType = SysOsType.NetWare_411; |
| | | }else if (isOpenVMS()) { |
| | | _instance.sysOsType = SysOsType.OpenVMS; |
| | | }else if (isOS2()) { |
| | | _instance.sysOsType = SysOsType.OS2; |
| | | }else if (isOS390()) { |
| | | _instance.sysOsType = SysOsType.OS390; |
| | | }else if (isOSF1()) { |
| | | _instance.sysOsType = SysOsType.OSF1; |
| | | }else if (isSolaris()) { |
| | | _instance.sysOsType = SysOsType.Solaris; |
| | | }else if (isSunOS()) { |
| | | _instance.sysOsType = SysOsType.SunOS; |
| | | }else if (isWindows()) { |
| | | _instance.sysOsType = SysOsType.Windows; |
| | | }else{ |
| | | _instance.sysOsType = SysOsType.Others; |
| | | } |
| | | return _instance.sysOsType; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(OSinfo.getOSname());// 获取系统类型 |
| | | System.out.println(OSinfo.isWindows());// 判断是否为windows系统 |
| | | } |
| | | |
| | | } |
| | | package com.zy.asrs.common.properties;
|
| | |
|
| | | /**
|
| | | * Created by vincent on 2020/8/1
|
| | | */
|
| | | public class OSinfo {
|
| | |
|
| | | private static final String OS = System.getProperty("os.name").toLowerCase();
|
| | |
|
| | | private static final OSinfo _instance = new OSinfo();
|
| | |
|
| | | private SysOsType sysOsType;
|
| | |
|
| | | private OSinfo(){}
|
| | |
|
| | | public static boolean isLinux(){
|
| | | return OS.contains("linux");
|
| | | }
|
| | |
|
| | | public static boolean isMacOS(){
|
| | | return OS.contains("mac") &&OS.indexOf("os")>0&& !OS.contains("x");
|
| | | }
|
| | |
|
| | | public static boolean isMacOSX(){
|
| | | return OS.contains("mac") &&OS.indexOf("os")>0&&OS.indexOf("x")>0;
|
| | | }
|
| | |
|
| | | public static boolean isWindows(){
|
| | | return OS.contains("windows");
|
| | | }
|
| | |
|
| | | public static boolean isOS2(){
|
| | | return OS.contains("os/2");
|
| | | }
|
| | |
|
| | | public static boolean isSolaris(){
|
| | | return OS.contains("solaris");
|
| | | }
|
| | |
|
| | | public static boolean isSunOS(){
|
| | | return OS.contains("sunos");
|
| | | }
|
| | |
|
| | | public static boolean isMPEiX(){
|
| | | return OS.contains("mpe/ix");
|
| | | }
|
| | |
|
| | | public static boolean isHPUX(){
|
| | | return OS.contains("hp-ux");
|
| | | }
|
| | |
|
| | | public static boolean isAix(){
|
| | | return OS.contains("aix");
|
| | | }
|
| | |
|
| | | public static boolean isOS390(){
|
| | | return OS.contains("os/390");
|
| | | }
|
| | |
|
| | | public static boolean isFreeBSD(){
|
| | | return OS.contains("freebsd");
|
| | | }
|
| | |
|
| | | public static boolean isIrix(){
|
| | | return OS.contains("irix");
|
| | | }
|
| | |
|
| | | public static boolean isDigitalUnix(){
|
| | | return OS.contains("digital") &&OS.indexOf("unix")>0;
|
| | | }
|
| | |
|
| | | public static boolean isNetWare(){
|
| | | return OS.contains("netware");
|
| | | }
|
| | |
|
| | | public static boolean isOSF1(){
|
| | | return OS.contains("osf1");
|
| | | }
|
| | |
|
| | | public static boolean isOpenVMS(){
|
| | | return OS.contains("openvms");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取操作系统名字
|
| | | * @return 操作系统名
|
| | | */
|
| | | public static SysOsType getOSname(){
|
| | | if(isAix()){
|
| | | _instance.sysOsType = SysOsType.AIX;
|
| | | }else if (isDigitalUnix()) {
|
| | | _instance.sysOsType = SysOsType.Digital_Unix;
|
| | | }else if (isFreeBSD()) {
|
| | | _instance.sysOsType = SysOsType.FreeBSD;
|
| | | }else if (isHPUX()) {
|
| | | _instance.sysOsType = SysOsType.HP_UX;
|
| | | }else if (isIrix()) {
|
| | | _instance.sysOsType = SysOsType.Irix;
|
| | | }else if (isLinux()) {
|
| | | _instance.sysOsType = SysOsType.Linux;
|
| | | }else if (isMacOS()) {
|
| | | _instance.sysOsType = SysOsType.Mac_OS;
|
| | | }else if (isMacOSX()) {
|
| | | _instance.sysOsType = SysOsType.Mac_OS_X;
|
| | | }else if (isMPEiX()) {
|
| | | _instance.sysOsType = SysOsType.MPEiX;
|
| | | }else if (isNetWare()) {
|
| | | _instance.sysOsType = SysOsType.NetWare_411;
|
| | | }else if (isOpenVMS()) {
|
| | | _instance.sysOsType = SysOsType.OpenVMS;
|
| | | }else if (isOS2()) {
|
| | | _instance.sysOsType = SysOsType.OS2;
|
| | | }else if (isOS390()) {
|
| | | _instance.sysOsType = SysOsType.OS390;
|
| | | }else if (isOSF1()) {
|
| | | _instance.sysOsType = SysOsType.OSF1;
|
| | | }else if (isSolaris()) {
|
| | | _instance.sysOsType = SysOsType.Solaris;
|
| | | }else if (isSunOS()) {
|
| | | _instance.sysOsType = SysOsType.SunOS;
|
| | | }else if (isWindows()) {
|
| | | _instance.sysOsType = SysOsType.Windows;
|
| | | }else{
|
| | | _instance.sysOsType = SysOsType.Others;
|
| | | }
|
| | | return _instance.sysOsType;
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | System.out.println(OSinfo.getOSname());// 获取系统类型
|
| | | System.out.println(OSinfo.isWindows());// 判断是否为windows系统
|
| | | }
|
| | |
|
| | | }
|