Desktop: browse(URI uri) : Desktop « java.awt « Java by API






Desktop: browse(URI uri)

 

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class Main {
  public static void main(String[] a) {
    try {
      URI uri = new URI("http://www.java2s.com");
      Desktop desktop = null;
      if (Desktop.isDesktopSupported()) {
        desktop = Desktop.getDesktop();
      }

      if (desktop != null)
        desktop.browse(uri);
    } catch (IOException ioe) {
      ioe.printStackTrace();
    } catch (URISyntaxException use) {
      use.printStackTrace();
    }

  }
}

   
  








Related examples in the same category

1.Desktop: edit(File file)
2.Desktop: getDesktop()
3.Desktop: isDesktopSupported()
4.Desktop: mail()
5.Desktop: open(File file)
6.Desktop: print(File file)