1 package zirc.base ; 2 3 import java.io.* ; 4 import java.util.* ; 5 6 19 26 27 28 48 49 public class BrowserLauncher 50 { 51 52 final String WIN_PATH = "rundll32" ; 53 final String WIN_FLAG = "url.dll,FileProtocolHandler" ; 54 final String UNIX_PATH = "netscape" ; 55 final String UNIX_FLAG = "-remote openURL" ; 56 57 public BrowserLauncher() 58 { 59 } 60 61 public void launchBrowserForLocalFiles(String url) 62 { 63 String os = System.getProperty("os.name") ; 64 StringTokenizer str = new StringTokenizer(os, " ") ; 65 os = str.nextElement().toString() ; 66 System.err.println(os) ; 67 68 if (os.equalsIgnoreCase("windows")) 69 { 70 String cmd = WIN_PATH + " " + WIN_FLAG + " " + url ; 71 try 72 { 73 Process p = Runtime.getRuntime().exec(cmd) ; 74 } 75 catch (IOException ex) 76 { 77 78 } 79 } 80 else { 82 if (os.equalsIgnoreCase("linux")) 83 { 84 String cmd = UNIX_PATH + " " + UNIX_FLAG + " " + url ; 85 try 86 { 87 Process p = Runtime.getRuntime().exec(cmd) ; 88 } 89 catch (IOException ex) 90 { 91 cmd = "konqueror " + url ; 92 try 93 { 94 Process p = Runtime.getRuntime().exec(cmd) ; 95 } 96 catch (IOException ex1) 97 { 98 } 99 } 100 } 101 102 } 103 104 } 105 106 public void launchBrowserForInternet(String url) 107 { 108 String os = System.getProperty("os.name") ; 109 StringTokenizer str = new StringTokenizer(os, " ") ; 110 os = str.nextElement().toString() ; 111 System.err.println(os) ; 112 113 if (os.equalsIgnoreCase("windows")) 114 { 115 String cmd = WIN_PATH + " " + WIN_FLAG + " " + url ; 116 try 117 { 118 Process p = Runtime.getRuntime().exec(cmd) ; 119 } 120 catch (IOException ex) 121 { 122 ex.printStackTrace() ; 123 } 124 } 125 else { 127 if (os.equalsIgnoreCase("linux")) 128 { 129 String cmd = UNIX_PATH + " " + UNIX_FLAG + " " + url ; 130 try 131 { 132 Process p = Runtime.getRuntime().exec(cmd) ; 133 } 134 catch (IOException ex) 135 { 136 cmd = "konqueror " + url ; 137 try 138 { 139 Process p = Runtime.getRuntime().exec(cmd) ; 140 } 141 catch (IOException ex1) 142 { 143 } 144 } 145 146 } 147 } 148 149 } 150 151 } 152 | Popular Tags |