Facing Problem in downloading file from FTP
843811Jun 25 2008 — edited Jun 26 2008Hi all,
I have written a piece of code to connect an FTP server and download/upload the file from/to the server to/from the local machine.
And i have tested my code by writing a java standalone application.Its downloading the file from the specified FTP location to my local machine.
Problem is when i am deploying the code in JBoss application server and trying to connect and download the file from the same FTP location its not happening.
Its successfully login to the FTP server but its not downloading the file .Its returning false in that retrieveFile()
method.
I am attaching the code whtever i ve written:
getFtpClient().changeWorkingDirectory(getRemoteDirectory()); //This line first returning false
FTPFile[] files = getFtpClient().listFiles();
for (int i = 0; i < files.length; i++) {
log.info("\t" + files.getName());
String localFileNameWithTimeStamp = getLocalFileNameWithTimeStamp(files[i]
.getName());
File file = new File(getLocalDirectory() + File.separator
+ localFileNameWithTimeStamp);
fos = new FileOutputStream(file);
*downLoad = getFtpClient().retrieveFile(files[i].getName(), fos);* //And here also its returning false
if (downLoad) {
String filePath = getLocalDirectory() + FILE_SEPARATOR
+ localFileNameWithTimeStamp;
fileNames.add(filePath);
}
}
Can anybody please help me on this...
I am struggleing on this from last 5 days to do something , but still the same result i am getting.
please help me on this...
Thnx in advance...
Regadrs
Debapriya