获取系统版本,判断是windows还是Linux

package com.foresee.zxpt.common.utils;

import java.util.Properties;

/**
 * 获取系统版本
 * @author GZ
 *
 */
public class OSUtils {

	/**
	 * 判断是否是Linux
	 * @return
	 */
	public static boolean isOSLinux() {
        Properties prop = System.getProperties();

        String os = prop.getProperty("os.name");
        if (os != null && os.toLowerCase().indexOf("linux") > -1) {
            return true;
        } else {
            return false;
        }
    }
	
	/**
	 * 判断是否是windows
	 * @return
	 */
	public static boolean isOSWin() {
		Properties prop = System.getProperties();
		
		String os = prop.getProperty("os.name");
		if (os != null && os.toLowerCase().startsWith("win")) {
			return true;
		} else {
			return false;
		}
	}
}
posted @ 2018-11-21 09:39  gaozhuang92  阅读(1956)  评论(0编辑  收藏  举报