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

FtpClient storeFile 總是返回 False

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

問題描述

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

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 并且文件沒有上傳到服務(wù)器上.有人請幫忙.

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

供您參考,我在辦公網(wǎng)絡(luò)中.--->我們需要添加任何代理嗎?

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...

請幫忙.

推薦答案

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

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

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

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 服務(wù)器返回碼列表.

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

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

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

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
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 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 欧美精品乱码久久久久久按摩 | 精品国产黄a∨片高清在线 成人区精品一区二区婷婷 日本一区二区视频 | 激情五月激情综合网 | 欧美在线一区二区三区四区 | 91久久久久| 国产精品不卡 | 国产精品亚洲一区二区三区在线观看 | 麻豆精品久久 | 欧美videosex性极品hd | 成人午夜视频在线观看 | 日韩中文字幕免费在线 | 免费观看www7722午夜电影 | 精品欧美一区二区久久久伦 | 亚洲精品乱码久久久久久蜜桃91 | 美女福利视频 | 中文字幕在线观看一区 | 91精品久久久久久久久久入口 | 亚洲一区免费在线 | 在线 丝袜 欧美 日韩 制服 | 九九热这里 | 麻豆国产一区二区三区四区 | www.99热.com | 97人人澡人人爽91综合色 | 欧美日韩国产高清 | 久久网站免费视频 | 91精品国产91久久久久福利 | 国产一区二区在线播放 | 狠狠狠干 | 久久出精品| 亚洲欧美视频一区 | 天天av天天好逼 | 亚洲精品综合一区二区 | 色在线免费视频 | 国产精品久久网 | 亚洲精品成人 | 国产成人av一区二区三区 | 欧洲精品在线观看 | 草草草久久久 | 欧美日韩国产在线观看 | 在线看片国产 | 国产露脸对白88av |