Basic HTML version of Foils prepared 17 Nov 97

Foil 47 Read a File on the Server II

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

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:
3 URLConnection conn = url.openConnection();
4 conn.connect(); // open a connection
5 Now use this URLConnection object to open a stream:
6 BufferedReader in =
  • new BufferedReader(
  • new InputStreamReader( conn.getInputStream() ) );
7 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 Wed Apr 1 1998