I am getting this error on the following code (note that this does not happen on my local machine, only on my build server):
Files.readAllBytes(Paths.get(get
You should get the resource through an InputStream
and not a File
, but there is no need for external libraries.
All you need is a couple of lines of code:
InputStream is = getClass().getResourceAsStream("/elasticsearch/segmentsIndex.json");
java.util.Scanner scanner = new java.util.Scanner(is).useDelimiter("\\A");
String json = scanner.hasNext() ? scanner.next() : "";
You can learn more about that method at https://stackoverflow.com/a/5445161/968244