Assuming you already have a directory, you can do something like this:
File directory= new File("user submits directory"); for (File file : directory.listFiles()) { if (FileNameUtils.getExtension(file.getName()).equals("txt")) {
The file NameNameUtils.getExtension () can be found here .
Edit: what you want to do is access the file structure from a web browser. According to this previous SO-mail, what you want to do is not possible due to security concerns.
source share