欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Java检测程序运行的操作系统类型,java检测程序运行,/*Check whic

来源: javaer 分享于  点击 16262 次 点评:152

Java检测程序运行的操作系统类型,java检测程序运行,/*Check whic


/*Check which operating system the program is running. The program explains itself.*/public class OSValidator {    public static boolean isWindows() {        String os = System.getProperty("os.name").toLowerCase();        return (os.indexOf("win") >= 0);    }    public static boolean isMac() {        String os = System.getProperty("os.name").toLowerCase();        return (os.indexOf("mac") >= 0);    }    public static boolean isUnix() {        String os = System.getProperty("os.name").toLowerCase();        return (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0);    }    public static boolean isSolaris() {        String os = System.getProperty("os.name").toLowerCase();        return (os.indexOf("sunos") >= 0);    }}
相关栏目:

用户点评