Skip to content

Instantly share code, notes, and snippets.

@alksily
Created March 1, 2019 12:26
Show Gist options
  • Save alksily/5ddd2ea1b9743217aae11cc6bad08660 to your computer and use it in GitHub Desktop.
Save alksily/5ddd2ea1b9743217aae11cc6bad08660 to your computer and use it in GitHub Desktop.
Detect operation system
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