Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.1k views
in Java FTP by (1k points)
hi,

I use java Thread to trigger ftp file transfers. i want to be able to cancel the transfer by user pressing a cancel button.

for this i call the FTPClient.cancelTransfer() method. it seems to work because when i checked file size after cancel it is less than total file size.
the problem is that i want to be able to delete the current canceled file when i call cancellTransfer(). does this method take care of that ?
logically it should.but i noticed the file remains in ftp server with incomplete size & it is tedious for me to track which file is canceled to delete it afterward.
any suggestion to deal with this issue is greatly welcomed.

thanks.

6 Answers

0 votes
by (162k points)
If you call cancelTransfer(), it stops the current transfer where it is up to. It does not delete the partially transferred file. Call delete() to do that.
0 votes
by (1k points)
thanks.

if i cancel a ftp upload i can delete the partially uploaded file .(indeed i had to quit() & reconnect before being able to delete ftp file).

however i'm facing a hard time to do same with file download:
if i cancel ftp download & try to delete partial file on local drive the File.delete() method fails.
it seems some other process (may bejavaw.ee or the Thread i use for download) is locking the file.
before calling File.delete() i call Thread.interrupt() to stop download thread i also set my thread object to null and call System.gc() .but still unable to delete the partial downloaded file.

can you help me fix this annoying issue ?

thanks much.
0 votes
by (162k points)
What version are you using of edtFTPj?
0 votes
by (1k points)
What version are you using of edtFTPj?

i use version 1.5.4 free edition
0 votes
by (162k points)
Can you post the code you are using?
0 votes
by (1k points)
thanks ,i solved the issue .
it was Thread.interrupt() method which didn't release the lock.
so i used another flag technique to terminate the Thread and exit run() method.

Categories

...