aspose file tools*
The moose likes Java in General and the fly likes how to search for a certain extension within a folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to search for a certain extension within a folder" Watch "how to search for a certain extension within a folder" New topic
Author

how to search for a certain extension within a folder

Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
Dear All
I want to search for a certain extention inside the folder
ie *.txt
how can i do this
thanks for help
Maha Aburahma
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
See this example from the Java Almanac.


"I'm not back." - Bill Harding, Twister
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
in DOS:

dir *.txt

in Linux:

ls *.txt


I'm a Hood Ornament
Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
Originally posted by Megs Maquito:
in DOS:

dir *.txt

in Linux:

ls *.txt



can i write
File dir = new File ("path");
String [] fileslist = dir.list("ls *.txt");
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
No, Megs' post tells how to do this from the command line, not from Java. If you look at the API for File, you will find there's no way to use list() with a String argument. (The fact that the code does not compile would be another clue.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to search for a certain extension within a folder