showfile.java

来自「介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识」· Java 代码 · 共 43 行

JAVA
43
字号
/** * 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 showfile extends Applet {			URL fileur;			TextArea showarea = new TextArea("I will get text",0,100);			public void init() {				String url = "http://www.bnu.edu.cn";				try {					fileur = new URL(url);				}				catch ( MalformedURLException e) {					System.out.println("Can't get URL: " );				}				add(showarea);			}			public void paint(Graphics g) {				InputStream filecon = null;				DataInputStream filedata = null;				String fileline;				try {					filecon = fileur.openStream();					filedata = new DataInputStream(filecon);					while ((fileline = filedata.readLine()) != null) {						showarea.setText(fileline+"\n");//.append(fileline+"\n");//.appendText(fileline+"\n");					}				}				catch (IOException e) {					System.out.println("Error in I/O:" + e.getMessage());				}			}		}

⌨️ 快捷键说明

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