If you want to manipulate the files using Java then you can use relative paths instead and take advantage of ClassLoader.
e.g. to read a file test.json inside test-folder under src/main/resources and get its contents in Java code:
InputStream is = getStreamFromResources("test-folder/test.json");
printFileContents(is);
If not inside a folder:
InputStream is = getStreamFromResources("test.json");
printFileContents(is);
Methods:
private static void printFileContents(InputStream inputStream) throws IOException {
StringBuilder textBuilder = new StringBuilder();
try (Reader reader = new BufferedReader(new InputStreamReader
(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) {
int c = 0;
while ((c = reader.read()) != -1) {
textBuilder.append((char) c);
}
}
jsonString = new String(textBuilder);
LOGGER.info(textBuilder.toString());
}
// get file contents as stream from classpath, resources folder
private InputStream getStreamFromResources(String fileName) {
ClassLoader classLoader = getClass().getClassLoader();
InputStream is = classLoader.getResourceAsStream(fileName);
if (is == null) {
throw new IllegalArgumentException("file is not found!");
} else {
return is;
}
}
This is how my folder structure looks like:

Sample Output in HTL:

Regards,
Ram