我正在尝试将文件从本地系统上传到ftp服务器的远程路径。 ftpClient.storeFile 始终返回false。我无法识别该错误。预先感谢。
public boolean upload(String srcPath, String destPath, String filename) {
InputStream inputStream = null;
try {
// connect(): basically creates and initialises the ftpClient object
connect();
File localFile = new File(srcPath + filename);
String remotePath = destPath + filename;
inputStream = new FileInputStream(localFile);
if(ftpClient.storeFile(remotePath, inputStream)) {
System.out.println("File uploaded successfully!!");
return true;
} else
System.out.println("Upload failed!!");
} catch (IOException ioExp) {
ioExp.printStackTrace();
} finally {
if(inputStream != null)
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
disconnect();
}
return false;
}