【发布时间】:2014-08-09 06:55:06
【问题描述】:
我知道 ftp 上传有多种格式。(二进制 ascii 等...)我正在编写一个简单的应用程序来在我的计算机和树莓派之间传输文件,我想知道是否有一种简单的方法来确保上传是正确的类型。此外,我一直在努力让 .jar 文件的上传成功,但没有成功。我相信这与已经提到的问题相同。这是代码
private void uploadActionPerformed(java.awt.event.ActionEvent evt) {
FileInputStream in = null;
int returnVal = filechooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = filechooser.getSelectedFile();
try{
FTPClient f = new FTPClient();
f.connect("********");
f.login("*******", "********");
in = new FileInputStream(file.getAbsolutePath());
f.storeFile("public_html/GEdropbox/" + file.getName(),in);
in.close();
f.disconnect();
}catch(IOException e){
System.out.println("not working");
}
} else {
System.out.println("File access cancelled by user.");
}
}
【问题讨论】:
-
捕获异常时,显示它的stackTrace。
标签: java apache ftp apache-commons apache-commons-net