//****************************************************************************** // count.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; import java.io.*; import java.net.*; import java.lang.Integer; //============================================================================== // Main Class for applet count // //============================================================================== public class count extends Applet { static DataInputStream rs; static DataOutputStream ws; static PrintStream ps; static int cnt; private URL count_url = null; private URL count_url2 = null; private URLConnection uc = null; // count Class Constructor //-------------------------------------------------------------------------- public count() { // TODO: Add constructor code here } public String getAppletInfo() { return "Name: count\r\n" + "Author: ³ëÁ¤¿À\r\n" + "Created with Microsoft Visual J++ Version 1.1"; } public void init() { String str; //byte buffer[] = new byte[3]; resize(20, 20); try { count_url = new URL("http://indy.imige.co.kr/~noon/Tmp/ttt.ttt"); rs = new DataInputStream(count_url.openStream()); } catch (IOException e) { System.out.println("File IO Error!!"); } try { cnt = rs.readInt(); rs.close(); } catch (IOException e) {} //file_Stream.close(); // TODO: Place additional initialization code here } public void destroy() { // TODO: Place applet cleanup code here } public void paint(Graphics g) { g.drawString(String.valueOf(cnt), 10, 20); } public void start() { String s = "hello\n"; cnt = cnt + 1; try { uc = count_url.openConnection(); uc.setDoOutput(true); } catch (IOException e) { System.out.println("Error in opening URLConnection"); } try { ws = new DataOutputStream(uc.getOutputStream()); } catch (Exception e) {} try { ws.writeBytes("test\r\n"); ws.flush(); } catch (IOException e) { System.out.println("Error in writeing to file"); } } public void stop() { } }