Java實現FTP斷定續傳__Java

來源:互聯網
上載者: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實用類  
* @version 0.1 實現基本斷點上傳下載  
* @version 0.2 實現上傳下載進度彙報  
* @version 0.3 實現中文目錄建立及中文檔案建立,添加對於中文的支援  
*/  
public class ContinueFTP2  implements Runnable{   
//枚舉類UploadStatus代碼 
public enum UploadStatus { 
Create_Directory_Fail,   //遠程伺服器相應目錄建立失敗 
Create_Directory_Success, //遠程伺服器闖將目錄成功 
Upload_New_File_Success, //上傳新檔案成功 
Upload_New_File_Failed,   //上傳新檔案失敗 
File_Exits,      //檔案已經存在 
Remote_Bigger_Local,   //遠程檔案大於本地檔案 
Upload_From_Break_Success, //斷點續傳成功 
Upload_From_Break_Failed, //斷點續傳失敗 
Delete_Remote_Faild;   //刪除遠程檔案失敗 

//枚舉類DownloadStatus代碼 
public enum DownloadStatus { 
Remote_File_Noexist, //遠程檔案不存在 
Local_Bigger_Remote, //本地檔案大於遠程檔案 
Download_From_Break_Success, //斷點下載檔案成功 
Download_From_Break_Failed,   //斷點下載檔案失敗 
Download_New_Success,    //全新下載檔案成功 
Download_New_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 ){   
        //設定將過程中使用到的命令輸出到控制台   
     ftpURL = _ftpURL; 
     username = _username; 
     pwd = _pwd; 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.