How to access a file in WEB-INF from a Java web application

Do you know how to access files in the WEB-INF / index folder from my application? I am using OpenCMS for my application and I want to open the Lucene search index (using the Lucene IndexReader class) located in the WEB-INF / index folder. The Lucene shortcut is stored in the WEB-INF / lib folder.

+1
source share
2 answers

If you want to find the file in RFS (real file system) in the WEB-INF folder, you can get the path through:

String filepath = pageContext.getServletContext().getRealPath("/") + "WEB-INF" + java.io.File.separator + "index";

and then use common java file methods to read it.

0
source

What do you intend to do with these index files?

OpenCms Lucene . Lucene OpenCms - , "" .

0

Source: https://habr.com/ru/post/1754144/


All Articles