Java: selecting a list of file names in a directory inside a war file

I have a web application in a servlet container.

How can I get a list of files inside a security folder inside a controller / servlet?

I tried something like this (which doesn't work):

File security_image_dir = new File("/beta/images/security/");
String security_images[] = security_image_dir.list();
+3
source share
1 answer

The standard way to access files in a web environment is ServletContext.getResourceAsStream (String) . If you want a list of files, you can try ServletContext.getResourcePaths ()

+5
source

All Articles