This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have come across one problem.I have a JAVA program which downloads file from the FTP.This is working fine. Now my requirment is like, if i send request to download file from FTP. Request is like ,consdier file name "myfile" then is there anyway by which i can download all the files which starts "myfile" on the FTP. file name could be like : myfile , myfile_x,Myfile_y,........ then the request should get all the file (from FTP) starts with myfile.
suggest me any api or anyway. ______________________________________________________ Mintoo ______________________________________________________
The FTP protocol itself can do this (the command is generally "mget" instead of "get"). Whether you can use that in your client depends on whether the FTP library you're using supports this.
It should always be to possible to list the contents of an FTP directory, and then to retrieve all files that match a particular pattern. You'd just have to do the matching in your code instead of having the library do it for you.
Joined: Aug 21, 2007
Thanks for the response.
I am using the edt.ftp libarary.which does not have method name like "mget" ,it has all the method which starts with "get" .
I too was thinking for the second option , to get list of file and make pattern using regex then find out.
to get list of file and make pattern using regex then find out
FTP servers don't give you a consistent directory listing format. The results differ depending on the ftp server you use. If you make your regular expression configurable, this will help you making the code usable with different servers.
OCUP UML fundamental and ITIL foundation
Joined: Mar 22, 2005
FTP servers don't give you a consistent directory listing format.
I would be very surprised if the FTP library in question (edt.ftp) doesn't abstract away those differences, just like other FTP client libraries (like Apache Commons Net) do.
Joined: Aug 21, 2007
yeah , correct I have made my regex pattern configrable and dynamic.So that it will not break. Because afte taking so much pain to discove the method ,which give me the all the file listing in a directory,finally i encountered with the method.
Hence ball is in my court so i will play with regex and the list(contains the name of the files).
I too have earlier used apache library where i could not remember exactly but there were some method like mget ,etc....But the problem is i have used this library and most of the other modules is using this library .Hence i can not push myself to change the library.