我知道有多種格式的ftp上傳(二進制ascii等...)我正在寫一個簡單的應用程序來在我的電腦和覆盆子pi之間傳輸文件,我想知道是否有是確保上傳是正確類型的一種簡單方法。另外,我一直在努力獲得一個.jar文件的上傳,但沒有成功。我相信這與前面提到的問題是一樣的。下面是代碼Apache commons java FTP上傳問題
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.");
}
}
當捕獲異常,表明它的堆棧跟蹤。 – MGorgon