import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.*; import java.net.*; public class ReadRemoteFiles extends Applet implements ActionListener { TextArea ta = new TextArea(); TextField tf = new TextField(); public void init() { setLayout(new BorderLayout()); add(tf, "North"); add(ta, "Center"); tf.requestFocus(); tf.addActionListener(this); } public void actionPerformed(ActionEvent ae) { URL u = null; InputStream in = null; try { String urlStr = tf.getText(); u = new URL(urlStr); in = u.openStream(); String outStr = ""; int ch; while ((ch = in.read()) != -1) outStr += (char)ch; ta.setText(outStr); } catch(Exception e) { ta.append("Problem\n"); ta.append(e.getMessage() + "\n"); } finally { try { if (in != null) in.close(); } catch(IOException e1) { } } } }