eriezelagera

OS Validator

Jun 28th, 2014
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. /**
  2.  * Detect which type of operating system (OS) you are using now. <br /> <br />
  3.  * <i>
  4.  * Source: http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/ <br /> <br />
  5.  * Modified by: Erieze Lagera <br />
  6.  * </i>
  7.  * @author Mkyong
  8.  */
  9. public class OSValidator {
  10.  
  11.     private static final String OS = System.getProperty("os.name").toLowerCase();
  12.  
  13.     public static boolean isWindows() {
  14.         return (OS.contains("win"));
  15.     }
  16.  
  17.     public static boolean isMac() {
  18.         return (OS.contains("mac"));
  19.     }
  20.  
  21.     public static boolean isUnix() {
  22.         return (OS.contains("nix") || OS.contains("nux") || OS.indexOf("aix") > 0 );
  23.     }
  24.  
  25.     public static boolean isSolaris() {
  26.         return (OS.contains("sunos"));
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment