Other useful stuff

July 09, 2011

List files in a directory

If you stored a lot of Gml files in a directory and want to retrieve them easily, you may use
another utility class to get a list witch could be filtered as well using a regular expression.
The static method of the FileUtils class may be used for this purpose.

This will list any file located in the “gml_folder” located at the root of your sketck.

List gmlFiles = FileUtils.scanFolder("gml_folder", "");

To retrieve .gml files only, you may use this in conjunction with a regular expression.

List gmlFiles = FileUtils.scanFolder("gml_folder", ".*\\.gml");

| Tags: , | More: Tutorials, Updates