1 23 24 29 30 package com.sun.enterprise.config.backup.util; 31 32 import java.io.*; 33 34 39 public class OS 40 { 41 private OS() 42 { 43 } 44 45 47 public static boolean isWindows() 48 { 49 return File.separatorChar == '\\'; 50 } 51 52 54 public static boolean isUNIX() 55 { 56 return File.separatorChar == '/'; 57 } 58 59 61 public static boolean isUnix() 62 { 63 return isUNIX(); 65 } 66 67 69 public static boolean isSun() 70 { 71 return is("sun"); 72 } 73 74 76 public static boolean isLinux() 77 { 78 return is("linux"); 79 } 80 81 83 public static boolean isWindowsForSure() 84 { 85 return is("windows") && isWindows(); 86 } 87 88 90 private static boolean is(String name) 91 { 92 String osname = System.getProperty("os.name"); 93 94 if(osname == null || osname.length() <= 0) 95 return false; 96 97 osname = osname.toLowerCase(); 99 name = name.toLowerCase(); 100 101 if(osname.indexOf(name) >= 0) 102 return true; 103 104 return false; 105 } 106 107 109 112 public static void main (String args[]) 113 { 114 System.out.println("isUNIX() returned: " + isUNIX()); 115 System.out.println("isWindows() returned: " + isWindows()); 116 System.out.println("isWindowsForSure() returned: " + isWindowsForSure()); 117 System.out.println("isSun() returned: " + isSun()); 118 System.out.println("isLinux() returned: " + isLinux()); 119 } 120 } 121 | Popular Tags |