首页 > Windows开发 > 详细

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

时间:2018-11-21 10:02:38      阅读:261      评论:0      收藏:0      [点我收藏+]
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;
		}
	}
}
x
42
        String os = prop.getProperty("os.name");
1
package com.foresee.zxpt.common.utils;
2
3
import java.util.Properties;
4
5
/**
6
 * 获取系统版本
7
 * @author GZ
8
 *
9
 */
10
public class OSUtils {
11
12
    /**
13
     * 判断是否是Linux
14
     * @return
15
     */
16
    public static boolean isOSLinux() {
17
        Properties prop = System.getProperties();
18
19
        String os = prop.getProperty("os.name");
20
        if (os != null && os.toLowerCase().indexOf("linux") > -1) {
21
            return true;
22
        } else {
23
            return false;
24
        }
25
    }
26
    
27
    /**
28
     * 判断是否是windows
29
     * @return
30
     */
31
    public static boolean isOSWin() {
32
        Properties prop = System.getProperties();
33
        
34
        String os = prop.getProperty("os.name");
35
        if (os != null && os.toLowerCase().startsWith("win")) {
36
            return true;
37
        } else {
38
            return false;
39
        }
40
    }
41
}
42

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

原文:https://www.cnblogs.com/gz9218/p/4002bbdf3490bb98a48ab866287f8f19.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!