This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am using org.apache.commons.net.ftp and have the following in my path:
My FTP server is on unix. Here is what I get when giving a command
on a windows command promt after connecting to the FTP Server output
I have an application that downloads the files from the above server, but I keep getting the following errors>>>>
Any idea what is wrong and how to fix it. Giving commands on command promt in windows works fine download, upload files. But when I use it through my program it gives errors. How else can get the files throgh java from FTP Server any other open source libraries available.
MB<br />Sun Certified Programmer for Java2 Platform
It would be polite to show us the code where the exception is taking place so we can see what is going on, but it appears to be when you are attempting to list the files on the server. Perhaps this entry from the Jakarta Commons Net FAQ will help you along:
Q: On which server operating systems is FTPClient able to bring back a parsed listing?
A: Currently parsers have been written for UNIX, Windows, OS/2, Netware, VMS and OS400. These can be autodetected by the code without being specified. Additionally, the code correctly handles cases where NT or OS400 servers have been configured to look like unix servers. There is also a means of specifying a user-written parser by class name. All of these parsers return FTPFile objects with as much information about the file as can be gathered from the listing.
If none of these is sufficient, FTPClient.listNames() may always be called. This retrieves just the file name without other information.
Okay. Then it seems to me that the quote that Joe Ess posted exactly describes your problem and what you have to do about it. There is a collection of available parsers in the org.apache.commons.net.ftp.parser package; presumably whatever decides what parser to use doesn't think any of them are appropriate for getting file lists from that server. You could try forcing it to use one of them, or you could write your own. Or you could talk to the person who manages the server and ask them if they can reconfigure it to use a more well-known file list format.
(This is happening to you because the FTP specifications don't require a server to use any particular format when returning a list of files, so over the years a number of commonly-used formats have evolved. But nothing requires servers to use any of those formats except the convenience of their clients.)
Joined: Jul 18, 2002
Any small example on how to use a specific parser. Even though listNames works fine just wanted if can still make use of listfiles.
As all I am trying to do is download files and then rename and some to delete.
Look at the source for some of the parsers built into the product you downloaded. It's open source so you can get the source code if you don't already have it. Then modify one of them to handle whatever the server is returning. It's going to take some debugging if the server's FTP file listing format is undocumented, which wouldn't surprise me.