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

📄 downloadfile.java

📁 MyDownloader 是一款使用 http 协议(RFC 1867)用于下载一个或多个文件到本地的简单易用的收费 Java 程序.使用托拽操作,你可以在一个页面内下载多个文件.在下载文件的过程当中
💻 JAVA
字号:
/*
 * Copyright 2007 JavaAtWork All rights reserved.
 * Use is subject to license terms.
 */
package com.javaatwork.mydownloader;

import java.net.URL;

/**
 * A holder class for storing the parameters of a file to download.
 * 
 * @author Johannes Postma
 */
public class DownloadFile {
	
	private URL url = null;
	private boolean overwrite = true;
	private String fileName = null;
	
	/**
	 * Creates a new DownloadFile.
	 * 
	 * @param url The location of the file.
	 */
	public DownloadFile(URL url) {
		this.url = url;
		
		String urlString = url.toString();
		int index = urlString.toString().lastIndexOf("/");
		if (index > 0) {
			fileName = urlString.substring(index + 1);
		} else {
			fileName = urlString; // may not be possible
		}
		
	}

	/**
	 * Creates a new DownloadFile.
	 * 
	 * @param url The location of the file.
	 * @param fileName The name of the file.
	 */
	public DownloadFile(URL url, String fileName) {
		this.url = url;
		this.fileName = fileName;
	}
	
	/**
	 * Returns the remote location of the file.
	 * 
	 * @return The remote location.
	 */
	public URL getUrl() {
		return url;
	}

	/**
	 * Sets the remote location of the file.
	 * 
	 * @param url The remote location.
	 */
	public void setUrl(URL url) {
		this.url = url;
	}
	
	/**
	 * Returns the file name.
	 * 
	 * @return The file name.
	 */
	public String getFileName() {
		return fileName;
	}

	/**
	 * True if the file already exists and it may be overwritten.
	 * 
	 * @return True if the file already exists and it may be overwritten otherwise false.
	 */
	public boolean isOverwrite() {
		return overwrite;
	}

	/**
	 * True if the file already exists and it may be overwritten.
	 * 
	 * @param overwrite True if the current file may be overwritten.
	 */
	public void setOverwrite(boolean overwrite) {
		this.overwrite = overwrite;
	}
}

⌨️ 快捷键说明

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