HELP! * YELLOW=global GREY=local Global HTML version of Foils prepared 4 February 97

Foil 51 Accessing URL's in Java -- URLConnection

From Feb 3 Delivered Lecture for Course CPS616 -- Java Lecture 4 -- AWT Through I/O CPS616 spring 1997 -- Feb 3 1997. by Nancy McCracken * See also color IMAGE
Secs 77.7
More interesting is to access a URL and process the information there!
This is done using streams:
There are methods in class URL --
InputStream in = instanceofURL.openStream(); // opens an InputStream associated with given url
More general is instanceofURL.openConnection() establishes a general connection and returns an instance of class URLConnection
  • This provides most general HTTP connectivity and indeed has some advantages over sockets as these are subject to special security restrictions in Netscape's current implementation
Note that one can connect not just to HTML files but also to CGI scripts i.e. programs at server and so obtain flexible connectivity


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 Sun Feb 16 1997