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

📄 fileuploadprogresslistener.java

📁 Upload file using DWR Ajax
💻 JAVA
字号:
/* * Xiaobo Yang, STFC e-Science Centre, Daresbury Laboratory, UK * Created: 30 April 2007 * Last modified: 30 April 2007 *  */package uk.ac.dl.esc.gtg.myportlets.fileupload;import java.text.NumberFormat;import org.apache.commons.fileupload.ProgressListener;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;public class FileUploadProgressListener implements ProgressListener {	private static Log log = LogFactory.getLog(FileUploadProgressListener.class);	private static long bytesTransferred = 0;	private static long fileSize = -100;	private long tenKBRead = -1;	public FileUploadProgressListener() {	}	public String getFileUploadStatus() {		// per looks like 0% - 100%, remove % before submission		String per = NumberFormat.getPercentInstance().format(				(double) bytesTransferred / (double) fileSize);		return per.substring(0, per.length() - 1);	}	public void update(long bytesRead, long contentLength, int items) {		// update bytesTransferred and fileSize (if required) every 10 KB is		// read		long tenKB = bytesRead / 10240;		if (tenKBRead == tenKB)			return;		tenKBRead = tenKB;		bytesTransferred = bytesRead;		if (fileSize != contentLength)			fileSize = contentLength;	}}

⌨️ 快捷键说明

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