I've got a folder in my Web Application, fonts. I'd like to get the path for each of those files in that directory. How do I do that? In asp.net I'd do something like:
System.IO.Directory.GetFiles(Server.MapPath("/fonts"))
I've got a folder in my Web Application, fonts. I'd like to get the path for each of those files in that directory. How do I do that? In asp.net I'd do something like:
System.IO.Directory.GetFiles(Server.MapPath("/fonts"))
java.io.File dir = new java.io.File("/fonts");
String[] files = dir.list();
You can use method getResourcePaths(String path) from ServletContext class for this purpose. It will return Set with directory-style listing of resources for specified (web-application mapped) path.
If you want to read content of file specified by mapped path, you can use method getResourceAsStream() from ServletContext returning InputStream for specified resource.