Java Reference
In-Depth Information
else
System.exit (0);
}
// actionPerformed
/** Display the println string on the text area **/
public void println (String str) {
fTextArea.append (str + "
\
n");
} // println
/** Display the print string on the text area **/
public void print (String str) {
fTextArea.append (str);
} // print
/** Create the frame and add the applet to it **/
public static void main (String[] args) {
int frame
-
width
=
200;
int frame
-
height
=
300;
// Create ReadFileViaURL object and add to the frame.
ReadFileViaURL applet
=
new ReadFileViaURL ();
applet.fInBrowser
=
false;
applet.init ();
// Create frame and then set its exit mode.
JFrame f = new JFrame ("Read file from URL Demo");
f.setDefaultCloseOperation (JFrame.EXIT
-
ON
-
CLOSE);
// Add applet to the frame
f.getContentPane ().add (applet);
f.setSize (new Dimension (frame
-
width, frame
-
height));
f.setVisible (true);
} // main
} // class ReadFileViaURL
13.6
InetAddress
The
java.net.InetAddress
class represents IP addresses. It works with
either a string host name such as
java.sun.com
or a numerical IP address such
as
64.124.81.56
. The
InetAddress
class has a number of useful methods
for dealing with host names and IP addresses. The demonstration programs below
illustrate some of the capabilities of the
InetAddress
class [2].
Search WWH ::
Custom Search