URL objects in Java
The class java.net.URL has methods to create and manipulate URL objects:
- String urlStr = "http://www.npac.syr.edu/";
- try {
- URL url = new URL( urlStr );
- }
- catch ( MalformedURLException e )
- { System.err.println( "Bad URL: " + urlStr );}
The document at this URL may be displayed in the current browser window with:
- getAppletContext().showDocument( url );
Another version of showDocument(...) permits the document to be loaded into an arbitrary HTML frame.