标题翻译
Transfer file to FTP java commons.net problem. No error, but no transfer
问题
我在传输文件到我的FTP时遇到了一些问题。使用这段代码,我没有收到任何错误,但文件也没有被传到我的FTP服务器上。希望一些经验丰富的用户能指点我正确的方向。
FTPClient client = new FTPClient();
FileInputStream picture = null;
try {
client.connect("地址", 端口);
client.login("用户", "密码");
client.changeWorkingDirectory("/htdocs/javaprojekt");
client.setFileType(FTP.BINARY_FILE_TYPE);
String filename = "/Users/sicknk/Documents/Java Projekt/fyeah.jpg";
picture = new FileInputStream(filename);
client.storeFile(filename, picture);
client.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (picture != null) {
picture.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
英文翻译
I'm having some trouble with transferring files to my ftp.
with this code i get no errors, but I also don't get a file to my ftp server. I hope some more experienced users can point me to the right direction.
FTPClient client = new FTPClient();
FileInputStream picture = null;
try {
client.connect("adress" ,port);
client.login("user", "password");
client.changeWorkingDirectory("/htdocs/javaprojekt");
client.setFileType(FTP.BINARY_FILE_TYPE);
String filename = "/Users/sicknk/Documents/Java Projekt/fyeah.jpg";
picture = new FileInputStream(filename);
client.storeFile(filename, picture);
client.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (picture != null) {
picture.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
专注分享java语言的经验与见解,让所有开发者获益!
评论