/ Published in: Java
Check which operating system the program is running. The program explains itself.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public class OSValidator { public static boolean isWindows() { // windows return (os.indexOf("win") >= 0); } public static boolean isMac() { // Mac return (os.indexOf("mac") >= 0); } public static boolean isUnix() { // linux or unix return (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0); } public static boolean isSolaris() { // Solaris return (os.indexOf("sunos") >= 0); } }