aspose file tools*
The moose likes I/O and Streams and the fly likes Retrieving specific file names under given path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Retrieving specific file names under given path" Watch "Retrieving specific file names under given path" New topic
Author

Retrieving specific file names under given path

yekkala krishna
Ranch Hand

Joined: Mar 04, 2007
Posts: 105
Hi,

I need to retrieve specific file names under given path.I am able to retrieve all the file names given in the specific path in the below code.now i need to retrieve only specific files like if pass html as argument i need to retrieve only html.


regards,
Rama Krishna Y>
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

File#listFiles() is an overloaded method and one version can accept a filter as an argument. Check the Javadoc for details.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
fioana elegant
Greenhorn

Joined: Oct 06, 2010
Posts: 16
if you are getting output like

E:\loginexample\abc.txt
E:\loginexample\abcd.txt
E:\loginexample\abcef.txt

then you can extract filename by substring function
take starting index 0 to lastIndexOf(\)

or

you can use

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retrieving specific file names under given path
 
Similar Threads
Doubt in a method of File class
A Mirroring Algorithm
Not able to retrieve files name s from a folder
Finding a file matching a pattern?
Scan through the entire workspace for specific directories in JAVA