3) If you try to load files off of the system where the applet is originally
stored, you will get a security exception and other error messages.
Package = java.net
java.net Classes and important methods
URL | This is a class that represents a URL. Can create an URLConnection object with its openConnection() method. |
URLConnection | This class represents a connection with a URL. Can use this to get an Inputer stream (getInputStream() method) to read/write information. |
Socket | Abstraction of standard TCP socket. Provides a client-side socket
interface similar to a standard UNIX socket. This provides Internet
connectivity beyond URL and URLConnection classes.
|
ServerSocket | In this case, a server-socket does not open a connection but instead
has a method action() that waits and listens on the TCP port for a connection
request from a client.
|
getInputStream() | This is a method of the URLConnection class. Will retrieve an InputStream to data I/O with the corresponding Internet/URL file. |
The Steps: 1) Create a URL object representing file 2) Create an URLConnection object that can load this URL and make a connection to the site hosting it. 3) Using getInputStream() method of the URLConnection object, create an InputStreamReader that can read from this URL. 4) If you wish create a different kind of reader,
e.g. BufferedReader, as we did before with File I/O to more efficiently
read the data as you wish.
|
Example_Application | Example_Applet |