i selecting files in java using following code:
file folder = new file("path folder"); file[] listoffiles = folder.listfiles();
now if want select image files?
use 1 of versions of file.listfiles()
accepts filefilter
or filenamefilter
define matching criteria.
for example:
file[] files = folder.listfiles( new filenamefilter() { public boolean accept(final file a_directory, final string a_name) { return a_name.endswith(".jpg"); // or use regular expression: // // return a_name.tolowercase().matches(".*\\.(gif|jpg|png)$"); // }; });
Comments
Post a Comment