Page 204 - 捷運技術 第28期
P. 204
198 28 92 2
Applet
Applet Java Applet
<APPLET code=screenfile.class width=90 height=80>
Applet ( )
public class screenfile extends JApplet implements ActionListener,Runnable
{
Thread timer;
JList list;
public void init()
{ timer=new Thread(this);
timer.start();}
public void run()
{while(true)
{this.readfile( alarm.txt ); //
try{Thread.sleep(5000 ); } // 5 1
catch(InterruptedException ie){}
}
public void readfile( String filname)
{ try { //
URL inp1= new URL (getCodeBase(),filname);
URLConnection con=inp1.openConnection();
InputStream ff=con.getInputStream();
BufferedReader hh=new BufferedReader(new InputStreamReader(ff));
String s;
while ( true)
{
s=hh.readLine();
if (s==null)
break;
list.add(s); } }
catch (MalformedURLException es){ }
catch (IOException ee){ }
}
Java Jsp Windows Linux Unix
MFC ++ VB
AFC