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

📄 webgrabber.java

📁 Class for downloading fileStreams from the internet
💻 JAVA
字号:
/*
 * Created on 8-mrt-2005
 *
 */

/**
 * @author Tom Deweerdt
 **/


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author Tim Waegeman
 */
public class WebGrabber {

	protected URL adress;

	protected BufferedReader in;

	/**
	 * Default constructor
	 */
	public WebGrabber() {
	}

	/**
	 * Constructor with param, URL webadress, which is the URL to download
	 * 
	 * @param webadress
	 *            a URL to a file online
	 * @throws MalformedURLException
	 */
	public WebGrabber(URL webadress) throws MalformedURLException {
		adress = webadress;
	}

	/**
	 * Sets the URL for WebGrabber to fetch
	 * 
	 * @param webadress
	 *            a URL to a file online
	 * @throws MalformedURLException
	 */
	public void setURL(URL webadress) throws MalformedURLException {
		adress = webadress;
	}

	/**
	 * Downloads the URL and gives it back as an BufferedReader. <BR>
	 * Note: always use closeDownload after using the BufferedReader from
	 * download
	 * 
	 * @return BufferedReader, downloaded file
	 * @throws IOException
	 * @throws URL
	 *             not set if the default constructor was used and no URL was
	 *             set.
	 * @see #setURL(URL)
	 */
	public BufferedReader download() throws IOException {
		if (adress == null)
			System.err.println(this.toString() + ": URL not set");
		return in = new BufferedReader(new InputStreamReader(adress.openStream()));
	}

	/**
	 * closes the BufferedReader or virtual download
	 */
	public void closeDownload() throws IOException {
		in.close();
	}

}

⌨️ 快捷键说明

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