通过Quartz调度器通过FTP下载java文件
我试着使用Ftp下载独立应用程序,效果很好。但当我将其包含到web应用程序中的Quartz调度器中时,它就失灵了
这就是我所做的
public class FtpTransfer implements StatefulJob {
public void execute(JobExecutionContext arg0) throws JobExecutionException {
FTPClient ftp = new FTPClient();
FileOutputStream br = null;
try
{
ftp.connect("localhost");
ftp.login("admin", "admin");
String path = "alfresco/MYPUB/Admin/TMM/Pickup";
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
ftp.changeWorkingDirectory(path);
System.out.println("After Changing Directory path");
FTPFile[] ftpFile = ftp.listFiles(path);
System.out.println("After getting list of files");
System.out.println("Length : "+ftpFile.length);
System.out.println("----------------- Downloaded -------------");
for(FTPFile tempFtpFiles : ftpFile) {
br = new FileOutputStream("e:\\Downloaded\\"+tempFtpFiles.getName());
ftp.retrieveFile(tempFtpFiles.getName(), br);
System.out.println(tempFtpFiles.getName());
}
System.out.println("------------------------------------------");
}
catch(Exception exception) {
System.out.println("Error : "+exception);
} finally {
try {
if(br!=null){
br.close();
}
ftp.disconnect();
} catch(IOException e) {
e.printStackTrace();
System.out.println("Error : "+e);
}
}
}
}
当我启动服务器时,它会打印
After Changing Directory path
After Changing Directory path
After Changing Directory path
每10秒。但它不是从给定的路径下载文件。仅此程序没有越过FTPFile[]FTPFile=ftp这一行。列表文件(路径)。我做错了什么
# 1 楼答案
谢谢你的评论。我发现了问题所在。包括雅加达奥罗之后。jar在lib中,工作正常