954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ftp file using wildcard with Java

Hi,

I would like to FTP a file that only part of the filename is known.
The name is something like “ClimateData2010042207XXXX.xls”
performing the following does not work:

FTPClient client = new FTPClient();
    FileOutputStream fos = null;
    client.connect("ftp.domain.com");
    client.login("admin", "secret");
    String filename = “ClimateData2010042207*.xls”;
    fos = new FileOutputStream(filename);
    client.retrieveFile("/" + filename, fos);
    fos.close();
    client.disconnect();


Please advice,
Yair

YairHa
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

FTP supports a mget command which can be used for retrieving multiple files based on the passed in file name/pattern. Look into your FTP client documentation for such support.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

Thanks, finaly I have used the wget command line that doing the work.

YairHa
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

Hi YairHa,

How do you use wget(or mget) with org.apache.commons.net.ftp.FTPClient ?

Thanks
Zen...

zenfaraad
Newbie Poster
1 post since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: