1 23 24 package org.dbforms.devgui; 25 26 import java.io.*; 27 28 29 30 33 public class BrowserTool { 34 41 public static void openURL(String anURL) throws IOException { 42 if (anURL.startsWith("http://") || anURL.startsWith("https://")) { 43 String osName = System.getProperties() 45 .getProperty("os.name") 46 .toLowerCase(); 47 System.out.println("os=" + osName); 48 49 if (osName.startsWith("win")) { 50 System.out.println("cmd /c start " + anURL); 51 Runtime.getRuntime() 52 .exec("cmd /c start " + anURL); 53 } 54 else { 56 System.out.println("netscape " + anURL); 57 Runtime.getRuntime() 58 .exec("netscape " + anURL); 59 } 60 } else { 61 throw new IOException("Protocol should be either http or https."); 62 } 63 } 64 } 65 | Popular Tags |