Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
13.1k views
in Java FTP by
Hi,

I am having problems with FTP get when I use dirDetails.
If I use dir, the get works fine.

Can anyone help?
Thanks

FTPFile[] remoteFileNames = ftpClient.dirDetails
(directory);
for (int i = 0; i < remoteFileNameslength; ++i)
{
remoteFileName = remoteFileNames[i].getName();
FileOutputStream fos = new FileOutputStream(localPath + "/" +
remoteFileName);

ftpClient.get(fos, remoteFileName);

}

10 Answers

0 votes
by (162k points)
What exception are you getting? Can you post the stack trace?

Hi,

I am having problems with FTP get when I use dirDetails.
If I use dir, the get works fine.

0 votes
by
I am getting:-

[2004-12-02 10:42:28.739] java.lang.Exception: Unable to download file <filename> from <ftp url>
0 votes
by (162k points)
We need a bit more info

- the log file
- the stack trace
- anything else that might help

what is <filename> and <ftp url>?

I am getting:-

[2004-12-02 10:42:28.739] java.lang.Exception: Unable to download file <filename> from <ftp url>
0 votes
by
I am catching an ftp exception and that is the exception thrown in the stack trace.
I cannot provide you with the name of the
RemoteHost and the URL, since its confidential.

Please let me know if this helps.

catch (FTPException e)
{
Logger.logException(e);
throw new Exception("Unable to download " + remoteFileName + " from " + remoteHostName +
" in directory " + localPath + " with login/password of " +
remoteLogin +
"/" + remotePassword);
}
0 votes
by (162k points)
Can you

ex.printStackTrace()?

I am catching an ftp exception and that is the exception thrown in the stack trace.
I cannot provide you with the name of the
RemoteHost and the URL, since its confidential.

Please let me know if this helps.

catch (FTPException e)
{
Logger.logException(e);
throw new Exception("Unable to download " + remoteFileName + " from " + remoteHostName +
" in directory " + localPath + " with login/password of " +
remoteLogin +
"/" + remotePassword);
}
0 votes
by
Here is the stack trace
[2004-12-03 13:31:34.9] com.enterprisedt.net.ftp.FTPException: temp.CSV.pgp: No such file or directory.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSoc
ket.java:725)
at com.enterprisedt.net.ftp.FTPClient.initGet(FTPClient.java:1238)
at com.enterprisedt.net.ftp.FTPClient.getBinary(FTPClient.java:1496)
at com.enterprisedt.net.ftp.FTPClient.get(FTPClient.java:1200)

Both versions of get
get(java.lang.String localPath, java.lang.String remoteFile)

( I use:-
ftpClient.get(localPath+ "/"+ remoteFileName, remoteFileName);
)

AND

get(java.io.OutputStream destStream, java.lang.String remoteFile)

( I use:-
FileOutputStream fos = new FileOutputStream(localPath + "/" + remoteFileName);
ftpClient.get(fos, remoteFileName);
)
failed for me.
0 votes
by (162k points)
Have you changed directory to the directory that the file is in?

Here is the stack trace
[2004-12-03 13:31:34.9] com.enterprisedt.net.ftp.FTPException: temp.CSV.pgp: No such file or directory.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSoc
ket.java:725)
at com.enterprisedt.net.ftp.FTPClient.initGet(FTPClient.java:1238)
at com.enterprisedt.net.ftp.FTPClient.getBinary(FTPClient.java:1496)
at com.enterprisedt.net.ftp.FTPClient.get(FTPClient.java:1200)

Both versions of get
get(java.lang.String localPath, java.lang.String remoteFile)

( I use:-
ftpClient.get(localPath+ "/"+ remoteFileName, remoteFileName);
)

AND

get(java.io.OutputStream destStream, java.lang.String remoteFile)

( I use:-
FileOutputStream fos = new FileOutputStream(localPath + "/" + remoteFileName);
ftpClient.get(fos, remoteFileName);
)
failed for me.
0 votes
by
I am doing a

FTPFile[] remoteFileNamesFound = ftpClient.dirDetails(remoteWorkingDirectory);

I don't need to change the directory.
0 votes
by (162k points)
But you are then doing a get() on a file listed in that directory - you will need to change into that directory to get the file.

I am doing a

FTPFile[] remoteFileNamesFound = ftpClient.dirDetails(remoteWorkingDirectory);

I don't need to change the directory.
0 votes
by
Thanks that worked. I was under the impression that dirDetails(remoteWorkingDirectory) switches the directory and a chdir is not reqd; but it seems it is.

Thanks a lot for your help.

Varsha

Categories

...