Basic HTML version of Foils prepared Sept 21 1998

Foil 47 Read a File on the Server II

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

ReadConnection class for Foil 47
1 A class called java.net.URLConnection provides another approach to URLs.
  • URLConnection provides the most general type of HTTP connectivity and indeed has some advantages over sockets (see following foils) as these are subject to special security restrictions in some browsers.
2 A method URL.openConnection() returns an instance of class URLConnection:
  • URLConnection conn = url.openConnection();
  • conn.connect(); // open a connection
  • Now use this URLConnection object to open a stream:
  • BufferedReader in =
  • new BufferedReader(
  • new InputStreamReader( conn.getInputStream() ) );
3 Note that one can connect not just to HTML files but also to CGI scripts and other web documents.

in Table To:


© 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 Sat Nov 28 1998