久久久久久久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(使用線程逐塊處理文件)
主站蜘蛛池模板: 精品九九在线 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 欧美日韩国产在线观看 | 最新国产精品 | 台湾a级理论片在线观看 | 黄网站涩免费蜜桃网站 | 久久国产精品99久久久久久丝袜 | 黑人精品| 国产成人精品一区二三区在线观看 | av片在线免费看 | 色婷婷精品国产一区二区三区 | 日韩精品一区二区久久 | 亚洲综合色视频在线观看 | 成人不卡在线 | 国产剧情一区 | 日韩在线一区二区三区 | 久久成人激情 | 久久av一区二区三区 | 羞羞视频网站免费看 | 亚洲一区久久 | 国产又色又爽又黄又免费 | 草久久| 9999国产精品欧美久久久久久 | 999精品在线| 日韩欧美网 | 国产丝袜av | 一区二区视频在线 | 波多野结衣精品在线 | 成人欧美一区二区三区黑人孕妇 | 日韩免费一区二区 | 国产精品99999999| 成人久久18免费网站麻豆 | 91精品国产99 | 日韩精品在线观看免费 | 久久精品二区 | 毛片一区二区三区 | 日韩欧美一区二区在线播放 | 国产精品国产精品国产专区不卡 | 日韩一区二区在线视频 | 国产精品区一区二 | 国产成人精品久久二区二区 |