| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

获取准确的操作系统名称的Java工具类

/**    * @see 获取操作系统名称    * @author Herman.Xiong    * @date 2014年4月22日 13:36:14    * @version V1.0    * @since jdk 1.6    */    public class OSUtil {        private static final boolean osIsMacOsX;        private static final boolean osIsWindows;        private static final boolean osIsWindowsXP;        private static final boolean osIsWindows2003;        private static final boolean osIsWindowsVista;        private static final boolean osIsLinux;        private static final boolean osIsWindowsWin7;        private static final boolean osIsWindowsWin8;            static {            String os = System.getProperty("os.name");            if (os != null)                os = os.toLowerCase();            osIsMacOsX = "mac os x".equals(os);            osIsWindows = os != null && os.indexOf("windows") != -1;            osIsWindowsXP = "windows xp".equals(os);            osIsWindows2003 = "windows 2003".equals(os);            osIsWindowsVista = "windows vista".equals(os);            osIsLinux = os != null && os.indexOf("linux") != -1;            osIsWindowsWin7 = os !=null && os.indexOf("windows 7") != -1;            osIsWindowsWin8 = os !=null && os.indexOf("windows 8") != -1;        }            public static boolean isMacOSX() {            return osIsMacOsX;        }            public static boolean isWindows() {            return osIsWindows;        }            public static boolean isWindowsXP() {            return osIsWindowsXP;        }            public static boolean isWindows2003() {            return osIsWindows2003;        }            public static boolean isWindowsVista() {            return osIsWindowsVista;        }            public static boolean isLinux() {            return osIsLinux;        }            public static boolean IsWindowsWin7(){            return osIsWindowsWin7;        }                public static boolean IsWindowsWin8(){            return osIsWindowsWin8;        }    }  
来自:http://blog.csdn.net/xmtblog/article/details/24305525

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1417072798581.html
Java工具类 Java开发