Created
March 1, 2019 12:26
-
-
Save alksily/5ddd2ea1b9743217aae11cc6bad08660 to your computer and use it in GitHub Desktop.
Detect operation system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.aengine.util; | |
public class OperationSystem { | |
public static OS getPlatform() { | |
String str = System.getProperty("os.name").toLowerCase(); | |
if(str.contains("win")) return OS.WINDOWS; | |
if(str.contains("mac")) return OS.MACOS; | |
if(str.contains("solaris")) return OS.SOLARIS; | |
if(str.contains("sunos")) return OS.SOLARIS; | |
if(str.contains("linux")) return OS.LINUX; | |
if(str.contains("unix")) return OS.LINUX; | |
return OS.UNKNOWN; | |
} | |
public static enum OS { | |
LINUX,SOLARIS,WINDOWS,MACOS,UNKNOWN; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment