Basic HTML version of Foils prepared 17 Nov 97

Foil 45 URL objects in Java

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo


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.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998