aspose file tools*
The moose likes Java in General and the fly likes FTP issue (using org.apache.commons.net.ftp) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "FTP issue (using org.apache.commons.net.ftp) " Watch "FTP issue (using org.apache.commons.net.ftp) " New topic
Author

FTP issue (using org.apache.commons.net.ftp)

Mike Boota
Ranch Hand

Joined: Jul 18, 2002
Posts: 82
Hi,

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.

Thanks


MB<br />Sun Certified Programmer for Java2 Platform
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Mike Boota
Ranch Hand

Joined: Jul 18, 2002
Posts: 82
Hi,

Here is a code snippet, also ftp.listNames(); works fine it's ftp.listFiles(); that fails.....



Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.)
Mike Boota
Ranch Hand

Joined: Jul 18, 2002
Posts: 82
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.

Thanks
Mike Boota
Ranch Hand

Joined: Jul 18, 2002
Posts: 82
Any help in how to set the parser. Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FTP issue (using org.apache.commons.net.ftp)