基本上,我有这条道路:
/data/data/pack.pack.pack/files/aaa/SQL
还有一个名为'SQL'的目录,它存在,但不知怎的,我得到了这个错误:
java.io.FileNotFoundException: /data/data/pack.pack.pack/files/aaa/SQL: open failed: EISDIR (Is a directory)
该方法成功上传其他文件夹,但不是这个(这是空的)
代码:
public void uploadSingleFileToFTP(File sFile, String pos){
FTPClient ftpClient = new FTPClient();
if(pos.isEmpty()){
pos = Init.FTP_UPLOAD_DIR_TARGET + getId() + pos;
}else{
if (sFile.isDirectory()){
pos = Init.FTP_UPLOAD_DIR_TARGET + getId() + pos;
}else{
//otherwise our folders will be empty on the server 999css - should be 999/css
pos = Init.FTP_UPLOAD_DIR_TARGET + getId()+ "/" + pos;
}
}
try {
ftpClient.connect(Init.SERVER_FTP_ADDRESS);
ftpClient.setSoTimeout(10000);
ftpClient.enterLocalPassiveMode();
if(ftpClient.login(Init.FTP_USER_NAME, Init.FTP_PASSWORD))
{
ftpClient.changeWorkingDirectory(pos);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
FileInputStream fs= new FileInputStream(sFile);
String fileName = sFile.getName();
Boolean result = ftpClient.storeFile(fileName, fs);
fs.close();
if(!result){
//display in long period of time
Toast.makeText(ctx, "Error while uploading" + sFile.getAbsolutePath(), Toast.LENGTH_LONG).show();
}
ftpClient.logout();
ftpClient.disconnect();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
可能导致错误的行:
FileInputStream fs= new FileInputStream(sFile);
很多很多:)