Invoking
cancelTransfer
will cancel the
currently executing transfer. To be able to call this method during a
transfer will require a separate thread. Once this method is called,
the transfer will cease once the current transfer buffer is emptied:
Cancelling
a transfer may leave the connection to the server in an inconsistent
state. After cancelling a transfer, it may be necessary to quit and
reconnect to the server.
Once
a transfer has been cancelled
or has been interrupted, resume
can be used to complete the
transfer. Please note
that resume
is only supported for binary mode transfers. For resuming
both uploads and downloads, it relies on
examining the partially downloaded or uploaded file to see how many
bytes remain to be transferred. The remaining bytes are then appended
to the partial file. To perform a resume, call resume,
and then
upload or download the file again, as shown below:
ftp.get(localFilename,
remoteFilename); // gets the rest of the file
Note
that resume only applies to the next transfer (upload or
download). The internal resume flag is reset once a transfer has been
made. If two transfers in a row need to be resumed,
resumeTransfer must be called prior to each
transfer.
Because
resumeTransfer relies only on the size of the partially downloaded or
uploaded file, it does not matter how long ago the transfer failed or
was terminated. As long as the partially transferred file is still
available (and of course the original file to be transferred
has not changed) , resuming the transfer will work correctly.
If resume is called erroneously, it can be cancelled by calling cancelResume. This means the next transfer will not be resumed, but will be transferred completely.