本文介绍了FtpClient storeFile总是返回False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请弄清楚这一点。代码正常运行,没有任何异常。
Please figure this out. The code runs properly without any exception.
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;
Buttttttttt
Buttttttttt
return语句总是返回false并且文件未上载到服务器上。有人请帮助。
return statement always return false and the file is not uploaded on the server. Some one please help on this.
您的信息,
1)我在办公室网络。 --->我们需要添加任何代理吗?
For your information,1) 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...
请帮助
推荐答案
通过调用。从那个页面(我的重点):
The exact failure message can be found by calling FtpClient#getReplyCode(). From that page (my emphasis):
要查看返回代码的含义,您可以看到。
To see what a return code means, you can see Wikipedia: List of FTP server return codes.
这篇关于FtpClient storeFile总是返回False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!