| How to pause and resume transfers |

At times network connections fail or processes are restarted, interrupting transfers. Also, it is sometimes necessary to terminate transfers, particularly for larger files that take a long time to transfer.
In these cases, it is often desirable to resume transfers rather than starting them from scratch - especially for large files. This means only the remaining part of the file is subsequently uploaded or downloaded.
Please note that resume is only supported for binary mode transfers. Because of line terminator translations, ASCII mode resumes are inpractical.
Invoking cancelAllTransfers() 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:
ftp.cancelAllTransfers(); // called from a different thread
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, it can be resumed to complete the transfer. 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, simply upload or download the file again, supplying the WriteMode.RESUME parameter.
ftp.download(localFilename, remoteFilename, WriteMode.RESUME);
Because resuming 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.
Please note: methods that use a stream instead of a local filename cannot be used in resuming - there is no way to find out how large the local file is.