Skip to content

Instantly share code, notes, and snippets.

@wowotek
Last active March 30, 2018 13:27
Show Gist options
  • Save wowotek/0f2417822ee496f00a2aef3a0777c064 to your computer and use it in GitHub Desktop.
Save wowotek/0f2417822ee496f00a2aef3a0777c064 to your computer and use it in GitHub Desktop.
Java Snippet for Checking Your Operating System
/**
* Simple Snippets For Checking Operating System
*
* @param None
* @return "*nix" for unix Based System, "macs" for Various MacOS Based System, "wint" for Windows
*/
private static String checkOS()
{
String _os = System.getProperty("os.name");
String ret_os = "null";
String[] l_os_unix =
{"Linux", "Solaris", "SunOS", "FreeBSD", "Irix",
"Digital Unix", "NetWare 4.11", "OSF1", "OpenVMS"};
String[] l_os_macs = {"Mac OS", "Mac OS X"};
String[] l_os_wint =
{"Windows 95", "Windows 98", "Windows Me", "Windows NT",
"Windows 2000", "Windows XP", "Windows 2003", "Windows CE"};
for(String i: l_os_unix)
if(_os.equals(i)){ret_os = "*nix"; break;}
for(String i: l_os_macs)
if(_os.equals(i)){ret_os = "macs"; break;}
for(String i: l_os_wint)
if(_os.equals(i)){ret_os = "wint"; break;}
return ret_os;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment