import java.awt.*; import java.io.*; import java.net.*; public class url1 extends Frame { TextField tf = new TextField(60); TextArea ta = new TextArea(15,60); public static void main(String[] args) { url1 a = new url1(); } url1() { setTitle("url1"); setLayout(new BorderLayout()); add("North", tf); add("Center", ta); pack(); show(); } public boolean action(Event e, Object o) { if (e.target == tf) { openurl(tf.getText()); return true; // handled } return false; // not handled } public void openurl(String s) { try { URL u = new URL(s); DataInputStream in = new DataInputStream(u.openStream()); String inline; ta.setText(""); while ((inline = in.readLine()) != null) { ta.appendText(inline); ta.appendText("\n"); } in.close(); } catch (Exception e) { ta.setText("Exception: " + e.toString()); } } }