Reading a file name placed in a FTP folder using Java

Hi Folks,

I have 2 files, One file A contains a reference number and using that reference number I need to find a file B in an FTP directory which has the reference number as part of the file name.

Example:

If the reference number is 123456 from File A, the file name B could be ABDCKLDL123456TXTY.txt.

Assuming that I have the reference number ready please give me a sample code to find the file B whose part of the name matches the Reference Number of FIle A

Regards
Kalyan.
kalyangkmAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

krakatoaCommented:
Call indexOf() on the filename Strings of the files in the target directory.
kalyangkmAuthor Commented:
Hi Folks,

Thanks for the reply, But could please be a bit elaborate on how I should connect to the FTP, It woud be helpful if I can get the sample code as I am bit of amateur in Java.

Regards
Kalyan.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

CEHJCommented:
Plenty of examples on the site of the aforementioned API

https://commons.apache.org/proper/commons-net/examples/ftp/FTPClientExample.java
kalyangkmAuthor Commented:
Hi Folks,

I found this very good blog which is exactly what I am looking and it works. Thanks for the inputs.

http://www.codejava.net/java-se/networking/ftp/java-ftp-example-search-for-files-and-directories

Regards
Kalyan.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
import org.apache.commons.net.ftp.FTPClient;

Open in new window


Good to see you're using the code i suggested
kalyangkmAuthor Commented:
I gave the correct resource from another website which works for my requirement.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.