Java implementation of FTP to determine the continued transmission __java
Source: Internet
Author: User
Package com.ftp;
Import java. io. File;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import Java.io.InputStream;
Import Java.io.OutputStream;
Import Java.io.PrintWriter;
Import Java.io.RandomAccessFile;
Import Org.apache.commons.net.PrintCommandListener;
Import Org.apache.commons.net.ftp.FTP;
Import org.apache.commons.net.ftp.FTPClient;
Import Org.apache.commons.net.ftp.FTPFile;
Import org.apache.commons.net.ftp.FTPReply;
Import Org.junit.Test;
/** *//**
* FTP utility to support breakpoint continuation
* @version 0.1 to achieve basic breakpoint upload download
* @version 0.2 Implementation upload Download progress report
* @version 0.3 implementation of Chinese directory creation and Chinese file creation, add support for Chinese
*/
public class ContinueFTP2 implements runnable{
Enumerating Class Uploadstatus Code
public enum Uploadstatus {
Create_directory_fail,//remote server corresponding directory creation failed
Create_directory_success,//remote server Pathbreaker directory succeeded
Upload_new_file_success,//upload new file successfully
Upload_new_file_failed,//failed to upload new file
File_exits,//file already exists
remote_bigger_local,//remote file is larger than local file
Upload_from_break_success,//Breakpoint continued success
upload_from_break_failed,//Breakpoint continuation failure
Delete_remote_faild; Failed to delete remote file
}
Enumerating Class Downloadstatus Code
public enum Downloadstatus {
Remote_file_noexist,//remote file does not exist
Local_bigger_remote,//local file is larger than remote file
Download_from_break_success,//breakpoint download file succeeded
download_from_break_failed,//Breakpoint download file failed
Download_new_success,//New download file successful
download_new_failed; New Download file failed
}
Public ftpclient ftpclient = new FtpClient ();
Private String Ftpurl,username,pwd,ftpport,file1,file2;
Public ContinueFTP2 (String _ftpurl,string _username,string _pwd,string _ftpport,string _file1,string _file2) {
Sets the command to output the commands used in the procedure to the console
Ftpurl = _ftpurl;
Username = _username;
PWD = _pwd;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service