import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; import java.applet.*; public class GetFileApplet2 extends Applet { Thread runner; URL page; static String page_name; TextArea box = new TextArea("Getting the text ...."); public void init() { URLConnection conn = null; InputStreamReader in; BufferedReader data; String line; StringBuffer buf = new StringBuffer(); page_name = new String(getParameter("URL")); setBackground(Color.yellow); add(box); try { page= new URL(page_name); } catch (MalformedURLException e) { System.out.println("Bad URL: " + page_name); } try { conn = page.openConnection(); //create a URLConnection object wiht page URL conn.connect(); //connect box.setText("Connection opened...."); in = new InputStreamReader(conn.getInputStream()); //get inputstream tied to URLConnection data = new BufferedReader(in); box.setText("Reading data......"); while((line = data.readLine()) != null) //while data still in URL stream { buf.append(line + "\n"); } box.setText(buf.toString());//dump contents of buffer into box TextArea } catch (IOException e) { System.out.println("IO Error:" + e.getMessage()); } } }