2013-11-23 49 views

回答

1

在這裏你去獲取操作系統類型,
How do I programmatically determine operating system in Java?

VonC的答案

public static final class OsUtils 
{ 
    private static String OS = null; 
    public static String getOsName() 
    { 
     if(OS == null) { OS = System.getProperty("os.name"); } 
     return OS; 
    } 
    public static boolean isWindows() 
    { 
     return getOsName().startsWith("Windows"); 
    } 

    public static boolean isUnix() // and so on 
} 
5

可以使用

System.getProperty("os.name") 
相關問題