-
FEATURED COMPONENTS
First time here? Check out the FAQ!
when I finish download the file use Filedownload,how do I delete the file。
我使用Filedownload进行文件下载后,怎么样才能够马上把服务器上的文件删除呢?
有没有Filedownload 的下载完毕事件呢
As long as you don't mind risking to lose the source file before you know for sure it's been successfully downloaded you can pass an input stream like this rather than the file itself:
public class DeleteOnCloseFileInputStream extends FileInputStream {
private File _file;
public DeleteOnCloseFileInputStream( File file ) throws FileNotFoundException {
super( file );
_file = file;
}
public File getFile() {
return _file;
}
public void dismiss() throws IOException {
_file = null;
super.close();
}
@Override
public void close() throws IOException {
try {
super.close();
} finally {
_file.delete();
_file = null;
}
} }
Regards.
Hello jerrylyj,
I found a very interesting post related to your issue:
http://forum.zkoss.org/question/20033/how-to-delete-a-file-after-his-download/
Best Regards,
Darksu
Asked: 2012-12-26 02:39:40 +0800
Seen: 92 times
Last updated: Nov 15 '16