get Os Type - Java java.lang

Java examples for java.lang:System

Description

get Os Type

Demo Code



public class Main{
    public static void main(String[] argv) throws Exception{
        System.out.println(getOsType());
    }/*from www .  ja v a 2 s  . co  m*/
    public static OsType getOsType() {
        String lvOS = System.getProperty("os.name").toLowerCase();
        if (lvOS.indexOf("win") > -1)
            return OsType.WINDOWS;
        else if (lvOS.indexOf("mac") > -1)
            return OsType.MAC;
        else
            return OsType.UNIX;
    }
}

Related Tutorials