//********************************************************************* //* 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.*; public class StreamTest extends Applet { TextArea theArea; FileInputStream fin; FileOutputStream fout; 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() { try { fin = new FileInputStream("index.html"); } catch(Exception e) { theArea.appendText("index.html open error...\n"); } try { fout = new FileOutputStream("index.out.html"); } catch(Exception e) { theArea.appendText("index.out.html open error...\n"); } } public void readFile() { byte b[] = new byte[1000]; int nr_read = 0; while(true) { try { nr_read = fin.read(b); } catch(Exception e) { } if(nr_read == -1) break; try { fout.write(b, 0, nr_read); } catch(Exception e) { } theArea.appendText(new String(b, nr_read)+"\n"); } } public boolean action(Event e, Object arg) { if(e.target instanceof Button) { if("Open file".equals(arg) == true) { openFile(); return true; } } return false; } }