Posted By

LucasRinaldi on 10/06/12


Tagged


Versions (?)

Operational System Validator


 / Published in: Java
 

Check which operating system the program is running. The program explains itself.

  1. public class OSValidator {
  2. public static boolean isWindows() {
  3. String os = System.getProperty("os.name").toLowerCase();
  4. // windows
  5. return (os.indexOf("win") >= 0);
  6. }
  7.  
  8. public static boolean isMac() {
  9. String os = System.getProperty("os.name").toLowerCase();
  10. // Mac
  11. return (os.indexOf("mac") >= 0);
  12. }
  13.  
  14. public static boolean isUnix() {
  15. String os = System.getProperty("os.name").toLowerCase();
  16. // linux or unix
  17. return (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0);
  18. }
  19.  
  20. public static boolean isSolaris() {
  21. String os = System.getProperty("os.name").toLowerCase();
  22. // Solaris
  23. return (os.indexOf("sunos") >= 0);
  24. }
  25. }

Report this snippet  

You need to login to post a comment.