//********************************************************************* //* Programmer : Jang Kyu-O(Àå ±Ô¿À) * //* Date : 1996/2/10 * //* E-Mail : kojang@ctkhost.ctk.co.kr * //* Tel : +82-02-3149-4821 * //* Address : Á¦À̾¾Çö ¿¤¸²³×Æ®»ç¾÷º»ºÎ À¥ÆÀ * //********************************************************************* import java.applet.*; import java.awt.*; import java.lang.*; import java.io.*; import java.net.*; public class StreamTest extends Applet { TextArea theArea; DataInputStream din; public void init() { setLayout(new BorderLayout()); Panel p = new Panel(); p.add(new Label("File editor....")); p.add(new Button("Open file")); add("North", p); add("Center", theArea = new TextArea()); theArea.appendText("Hello!!!\n\n press the open button...\n"); } public void openFile() { URL url=null; try { url = new URL(getCodeBase(), "index.html"); din = new DataInputStream(url.openStream()); } catch(Exception e) { theArea.appendText("index.html open error...\n"); } } public void readFile() { String line=null; while(true) { try { if((line = din.readLine()) == null) break; } catch(Exception e){ break; } theArea.appendText(line+"\n"); } } public boolean action(Event e, Object arg) { if(e.target instanceof Button) { if("Open file".equals(arg) == true) { openFile(); readFile(); return true; } } return false; } }