1 21 24 package org.lobobrowser.util; 25 26 29 public class OS { 30 33 private OS() { 34 super(); 35 } 36 37 public static boolean isWindows() { 38 String osName = System.getProperty("os.name"); 39 return osName.indexOf("Windows") != -1; 40 } 41 42 public static void launchBrowser(String url) throws java.io.IOException { 43 String cmdLine; 44 if(isWindows()) { 45 cmdLine = "rundll32 url.dll,FileProtocolHandler " + url; 46 } 47 else { 48 cmdLine = "firefox " + url; 49 } 50 try { 51 Runtime.getRuntime().exec(cmdLine); 52 } catch(java.io.IOException ioe) { 53 Runtime.getRuntime().exec("netscape " + url); 54 } 55 } 56 57 60 public static void launchPath(String path) throws java.io.IOException { 61 if(isWindows()) { 62 Runtime.getRuntime().exec(new String [] { "cmd.exe", "/c", "start", "\"title\"", path }); 63 } 64 else { 65 throw new UnsupportedOperationException ("Unsupported"); 66 } 67 } 68 69 public static boolean supportsLaunchPath() { 70 return isWindows(); 71 } 72 } 73 | Popular Tags |