久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

FtpClient storeFile 總是返回 False

FtpClient storeFile always return False(FtpClient storeFile 總是返回 False)
本文介紹了FtpClient storeFile 總是返回 False的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

請解決這個問題.代碼運行正常,沒有任何異常.

Please figure this out. The code runs properly without any exception.

try
{
    FTPClient ftp = new FTPClient();
    ftp.connect(server);
    if(!ftp.login(username, password))
    {
        ftp.logout();
        return false;
    }
    int reply = ftp.getReplyCode();
    if (!FTPReply.isPositiveCompletion(reply))
    {
        ftp.disconnect();
        return false;
    }
    InputStream in = new FileInputStream(localfile);
    ftp.setFileType(ftp.BINARY_FILE_TYPE, ftp.BINARY_FILE_TYPE);
    ftp.setFileTransferMode(ftp.BINARY_FILE_TYPE);
    Store = ftp.storeFile(destinationfile, in);
    in.close();
    ftp.logout();
    ftp.disconnect();
}
catch (Exception ex)
{
    ex.printStackTrace();
    return false;
}
return Store;

但是 return 語句總是返回 false 并且文件沒有上傳到服務器上.有人請幫忙.

Butm the return statement always returns false and the file is not uploaded on the server. Someone please help on this.

供您參考,我在辦公網絡中.--->我們需要添加任何代理嗎?

For your information, I am in an office network. ---> do we need to add any proxies?

File file = new File("C:\Users\sg0214273\Desktop\seagate\seagate.txt");
FileInputStream input = new FileInputStream(file);
client.setFileType(FTP.BINARY_FILE_TYPE);
if (!client.storeFile(file.getName(), input)) {
  System.out.println("upload failed!");
} 
reply = client.getReplyCode();

if(!FTPReply.isPositiveCompletion(reply)) {
  System.out.println("upload failed!");
}

Login success...
230 User ******** logged in.
upload failed!-----> is form boolean return value of storefile 
upload failed!---------> is from replycode...
Logout from FTP server...

請幫忙.

推薦答案

可以通過調用FtpClient#getReplyCode().從該頁面(我的重點):

The exact failure message can be found by calling FtpClient#getReplyCode(). From that page (my emphasis):

連接后立即是您需要檢查的唯一實時時間回復代碼(因為 connect 是 void 類型).該公約為FTPClient 中的所有 FTP 命令方法都是這樣的返回一個布爾值或其他一些值.布爾方法返回如果來自 FTP 服務器的成功完成回復,則為 true,如果為 false導致錯誤情況或失敗的回復.方法返回一個布爾值以外的值,返回一個包含由 FTP 命令生成的更高級別的數據,如果回復則為 null導致錯誤情況或失敗.如果您想訪問導致成功或失敗的確切 FTP 回復代碼,您必須調用在成功或失敗后獲取回復代碼.

Immediately after connecting is the only real time you need to check the reply code (because connect is of type void). The convention for all the FTP command methods in FTPClient is such that they either return a boolean value or some other value. The boolean methods return true on a successful completion reply from the FTP server and false on a reply resulting in an error condition or failure. The methods returning a value other than boolean return a value containing the higher level data produced by the FTP command, or null if a reply resulted in an error condition or failure. If you want to access the exact FTP reply code causing a success or failure, you must call getReplyCode after a success or failure.

要了解返回碼的含義,您可以查看維基百科:FTP 服務器返回碼列表.

To see what a return code means, you can see Wikipedia: List of FTP server return codes.

這篇關于FtpClient storeFile 總是返回 False的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 国产高清久久 | 午夜免费网站 | 国产成人精品福利 | 成人欧美一区二区三区在线观看 | 久久精品91久久久久久再现 | 日韩快播电影 | 久久福利网站 | 欧美精品一区在线发布 | 亚洲精品电影网在线观看 | 色综合色综合网色综合 | 欧美精品一区在线 | 亚洲成人一区二区三区 | 亚洲高清视频在线观看 | 国产aa | 中文字幕在线视频一区二区三区 | 亚洲精品一区二区三区在线 | 天天综合成人网 | 很黄很污的网站 | 天天色天天射天天干 | 欧美性另类 | 久久天堂网 | 99久久婷婷| 欧美福利专区 | 国产在线对白 | 久久大陆 | 亚洲第一福利网 | 久久综合色综合 | 人人看人人搞 | 日韩一级不卡 | 国产色婷婷精品综合在线手机播放 | 精品国产一区二区三区久久影院 | 午夜电影日韩 | 午夜影院 | 久久国产精品久久久久 | 农村真人裸体丰满少妇毛片 | 日本久草 | 亚洲精品视频在线播放 | 欧美韩一区二区三区 | 精品国产一区二区三区日日嗨 | 欧美日韩国产高清视频 | 成人妇女免费播放久久久 |