I have a directory, C:\myDir
.
under this directory, there may be folders and various files
How can I "loop" through this directory and build up a File array of all files with a .properties
extension?
I want to do some processing on these files, the reason for a File[] is to keep it dynamic (so additional properties files added in the future will be included)
I'm hoping to do something like this :
public static void main (String[] vargs)
{
// find all .properties files
//
//loop through property file and process
{
doSomething(myFile[i]);
}
}
public void doSomething(File myfile) {}
Look at FilenameFilter.
final FilenameFilter filter = new FilenameFilter() {
public boolean accept(final File directory, final String name) {
return name.endsWith(".properties");
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With