File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to search for text files inside a folder ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to search for text files inside a folder ?" Watch "How to search for text files inside a folder ?" New topic
Author

How to search for text files inside a folder ?

Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

I want to :

1.Search for a TEXT file with a particular name inside a folder.
2.Store the name of this file in a string inside any java program.

Can you guide me ?


SCJP 6. Learning more now.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3011
    
    9
Take a look at the File class


Joanne
Shawn Smith
Ranch Hand

Joined: Feb 22, 2011
Posts: 41
You can try something like




Though this won't give you a recursive answer, you can certainly build up a looping construct that will.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

Hi Shawn, welcome to the Ranch, and thanks for contributing!

Just one little thing... I added the "code tags" to your code. See how much more readable it is? All you have to do when you're posting code is to highlight the code and click the "Code" button which is above the box you're posting in.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to search for text files inside a folder ?
 
Similar Threads
neep help - files inside folder structure
eclipse problems during start up
better Eclipse plugin to do searching
java code to create a folder and save a text file in it..!!