Help,when I finish download the file use Filedownload,how do I delete the file

asked 2012-12-26 02:39:40 +0800

jerrylyj gravatar image jerrylyj
12 1

when I finish download the file use Filedownload,how do I delete the file。
有没有Filedownload 的下载完毕事件呢

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2015-09-01 07:13:10 +0800

cvarona gravatar image cvarona
554 1 6

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;

    public void close() throws IOException {
        try {
        } finally {
            _file = null;
    } }


link publish delete flag offensive edit

answered 2015-09-06 10:01:06 +0800

Darksu gravatar image Darksu
1991 1 4

Hello jerrylyj,

I found a very interesting post related to your issue:


Best Regards,


link publish delete flag offensive edit

answered 2016-11-15 09:27:36 +0800

janfran gravatar image janfran

Thank you Cvarona, it works well!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2012-12-26 02:39:40 +0800

Seen: 92 times

Last updated: Nov 15 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More