⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dynashow.java

📁 动态获取网站信息程序源码.功能还可以,希望站长能满意.
💻 JAVA
字号:
/** * Title:        Java网络编程演示 * Description:  Java网络编程演示,用于北京师范大学计算机系Java课程教学示范。 * Copyright:    Copyright (c) 2001 * Company:      北京师范大学计算机系 * @author 孙一林 * @version 1.0 */import java.io.*;import java.net.*;import java.awt.*;import java.applet.*;public class dynashow extends java.applet.Applet	implements Runnable {	Thread dthread;	URL fileur;	TextArea showarea = new TextArea("Wait for a while...",00,100);	public void init() {		String url = " http://www.bnu.edu.cn/index.html";		try {			fileur = new URL(url);		}		catch ( MalformedURLException e) {			System.out.println("Can't open the URL: " );		}		add(showarea);	}	public void start() {		if (dthread == null) {			dthread = new Thread(this);			dthread.start();		}	}	public void stop() {		if (dthread != null) {			dthread.stop();			dthread = null;		}	}	public void run() {		InputStream filecon = null;		DataInputStream filedata = null;		String fileline;		while(true) {			try {				filecon = fileur.openStream();				filedata = new DataInputStream(filecon);				while ((fileline = filedata.readLine()) != null) {					showarea.setText(fileline+"\n");//.appendText(fileline+"\n");				}			}			catch (IOException e) {				System.out.println("Error in I/O:" + e.getMessage());			}			try {				dthread.sleep(5000);			}			catch (InterruptedException e) { }			repaint();		}	}	public static void main(String[] args) {          // 定义Application程序入口	    Frame f = new Frame("动态获取网络资源");              // 定义窗体	    dynashow dynashow1 = new dynashow();	    dynashow1.init();	    dynashow1.start();                            // 启动程序	    f.add("Center",dynashow1);                    // 显示在窗体内	    f.setSize(480,300);	    f.show();	  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -