本文整理汇总了Java中org.apache.commons.fileupload.ProgressListener类的典型用法代码示例。如果您正苦于以下问题:Java ProgressListener类的具体用法?Java ProgressListener怎么用?Java ProgressListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProgressListener类属于org.apache.commons.fileupload包,在下文中一共展示了ProgressListener类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
/**
* 方法(受保护)<br>
* 名称: init<br>
* 描述: Servlet初始化时调用此方法,初始化连接器以及数据层接口的实现方法<br>
*
* @throws javax.servlet.ServletException
*/
@Override
public void init() throws ServletException
{
super.init();
//初始化文件上传器
this.fileUploader=new FileUploader(UPLOAD_PATH,ACCEPT_TYPES,MAX_SIZE,MAX_FILE_SIZE);
// 根据实际情况设置对象属性(可选)
//设置名字生成器
/*this.fileUploader.setFileNameGenerator(new FileNameGenerator()
{
@Override
public String generate(FileItem item,
String suffix)
{
return String.format("%d_%d", item.hashCode(), item.get().hashCode());
}
});*/
//设置进度监听器
this.fileUploader.setServletProgressListener(
new ProgressListener()
{
@Override
public void update(long pBytesRead,
long pContentLength,
int pItems)
{
System.out.printf("%d: length -> %d, read -> %d.\n",pItems,pContentLength,pBytesRead);
}
}
);
}
示例2: init
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
/**
* 方法(受保护)<br/>
* 名称: init<br/>
* 描述: Servlet初始化时调用此方法,初始化连接器以及数据层接口的实现方法<br/>
*
* @throws javax.servlet.ServletException
*/
@Override
public void init() throws ServletException
{
super.init();
//初始化文件上传器
this.fileUploader=new FileUploader(UPLOAD_PATH,ACCEPT_TYPES,MAX_SIZE,MAX_FILE_SIZE);
this.processor=new ImageProcessor();
// 根据实际情况设置对象属性(可选)
//设置名字生成器
/*this.fileUploader.setFileNameGenerator(new FileNameGenerator()
{
@Override
public String generate(FileItem item,
String suffix)
{
return String.format("%d_%d", item.hashCode(), item.get().hashCode());
}
});*/
//设置进度监听器
this.fileUploader.setServletProgressListener(
new ProgressListener()
{
@Override
public void update(long pBytesRead,
long pContentLength,
int pItems)
{
System.out.printf("%d: length -> %d, read -> %d.\n",pItems,pContentLength,pBytesRead);
}
}
);
}
示例3: addListener
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
public void addListener(String id, ProgressListener listener)
{
String key = getKey(id);
sessionService.setAttribute(key, listener);
}
示例4: getUploadFileListener
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
public ProgressListener getUploadFileListener() {
return __uploadFileListener;
}
示例5: setServletProgressListener
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
/**
* 设置上传组件的处理进程监听器,参考:{@link ServletFileUpload#setProgressListener(ProgressListener)}
*
* @param servletProgressListener
*/
public void setServletProgressListener(
ProgressListener servletProgressListener)
{
this.servletProgressListener=servletProgressListener;
}
示例6: getUploadFileListener
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
/**
* @return 文件上传状态监听器
*/
ProgressListener getUploadFileListener();
示例7: ProgressNotifier
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
/**
* Creates a new instance with the given listener
* and content length.
*
* @param pListener The listener to invoke.
* @param pContentLength The expected content length.
*/
ProgressNotifier(ProgressListener pListener, long pContentLength) {
listener = pListener;
contentLength = pContentLength;
}
示例8: getServletProgressListener
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
/**
* 获取上传组件的处理进程监听器,参考:{@link ServletFileUpload#getProgressListener()}
*
* @return
*/
public ProgressListener getServletProgressListener()
{
return servletProgressListener;
}
示例9: ProgressNotifier
import org.apache.commons.fileupload.ProgressListener; //导入依赖的package包/类
/** Creates a new instance with the given listener
* and content length.
* @param pListener The listener to invoke.
* @param pContentLength The expected content length.
*/
ProgressNotifier(ProgressListener pListener, long pContentLength) {
listener = pListener;
contentLength = pContentLength;
}