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

📄 urlgetfile.java

📁 java程序设计源代码
💻 JAVA
字号:
import java.io.*; 
import java.net.*; 
import java.awt.*;
import java.awt.event.*;
import java.applet.*; 
public class URLGetFile extends Applet{ 
	URL url; 
	TextArea showarea = new TextArea("下载的数据:"); 
	public void init() { 
		String strurl = "http://localhost/tmp"; 
		try { 
			url = new URL(strurl);  
		}catch ( MalformedURLException e) { 
			System.out.println("URL格式有错" ); 
		}
		add(showarea);
	} 

	public void start() { 
		InputStream filecon = null; 
		BufferedReader filedata = null; 
		String line; 
		try { 
			filecon = url.openStream(); 
			filedata = new BufferedReader(new InputStreamReader(filecon)); 
			while ((line = filedata.readLine()) != null) { 
				showarea.append(line+"\n"); 
			} 
		}catch (IOException e) { 
			System.out.println("Error in I/O:" + e.getMessage()); 
		} 
	} 
	public static void main( String[] args){
		Frame f = new Frame("URL Test");
		Applet ap = new URLGetFile();
		ap.init();
		f.add(ap);
		f.addWindowListener( new WindowAdapter(){
			public void windowClosing(WindowEvent e){System.exit(0);}
		});
		f.setSize( 400,300 );
		f.show();
		ap.start();
	}
} 

⌨️ 快捷键说明

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