Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1.  
  2. /**
  3. * To switch and find the current Operating system.
  4. *
  5. */
  6. public enum OS {
  7. WINDOWS, MAC, LINUX, OTHER
  8. }
  9.  
  10. /**
  11. * Returns the location of the AppData directory
  12. *
  13. * @return String representation of the AppData directory
  14. */
  15. public static String getAppData() {
  16. return getOS() == OS.WINDOWS ? System.getenv("APPDATA") : System.getProperty("user.home");
  17. }
  18.  
  19. /**
  20. * Returns the OS system for basic configuration
  21. *
  22. * @return Returns an enumerator for the OS.
  23. */
  24. private static OS getOS() {
  25. String os = System.getProperty("os.name").toLowerCase();
  26. if (os.contains("windows")) {
  27. return OS.WINDOWS;
  28. }
  29. if (os.contains("mac")) {
  30. return OS.MAC;
  31. }
  32. if (os.contains("linux")) {
  33. return OS.LINUX;
  34. }
  35. return OS.OTHER;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement