zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java识别操作系统详解编程语言

2023-06-13 09:20:46 时间
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"; 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 } 23 public static void main(String[] args) { 24 System.out.println(getDevNull()); 25 } 26 }

 

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/15994.html

cjavawindows