Java Reference
In-Depth Information
catch (MalformedURLException e) {
fTextArea.append ( " Malformed URL =" + e);
System.out.println (" Malformed URL =" + e);
return;
}
// Now open a stream to the file using the URL.
try {
InputStream in = url.openStream ();
BufferedReader dis = new BufferedReader (
new InputStreamReader (in));
fBuf = new StringBuffer ();
while ((line = dis.readLine ())! = null) {
fBuf.append (line + " \ n " );
}
in.close ();
}
catch (IOException e) {
fTextArea.append ("IO Exception ="+ e);
System.out.println ("IO Exception ="+ e);
return;
}
// Load the file into the TextArea.
fTextArea.append (fBuf.toString ());
} // readFile
/**
* Can use the start() method, which is called after
* init() and the display has been created.
**/
public void start () {
// Now read the file.
readFile ();
} // start
/** Respond to the buttons **/
public void actionPerformed (ActionEvent e) {
string source = e. getActionCommand ();
if (source.equals ("Go"))
start ();
else if (source.equals ("Clear"))
fTextArea.setText (null);
 
Search WWH ::




Custom Search