Java识别操作系统
1 /**2 * Created by xfyou on 2016/11/3.
3 */
4 public class SysDep {
5 final static String UNIX_NULL_DEV = "/dev/null";
6 final static String WINDOWS_NULL_DEV = "NULL";
7 final static String FAKE_NULL_DEV = "jnk";
8
9 public static String getDevNull() {
10 if (new File(UNIX_NULL_DEV).exists()) {
11 return UNIX_NULL_DEV;
12 }
13 String sys = System.getProperty("os.name");
14 if (sys == null) {
15 return FAKE_NULL_DEV;
16 }
17 if (sys.startsWith("Windows")) {
18 return WINDOWS_NULL_DEV;
19 }
20 return FAKE_NULL_DEV;
21 }
22
23 public static void main(String[] args) {
24 System.out.println(getDevNull());
25 }
26 }
以上是 Java识别操作系统 的全部内容, 来源链接: utcz.com/z/392796.html