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
Don't try to access a resource like a file. Just grab the InputStream and read the data from there:
byte[] data;
try (InputStream in = getClass().getResourceAsStream("/elasticsearch/segmentsIndex.json")) {
data = in.readAllBytes(); // usable in Java 9+
// data = IOUtils.toByteArray(in); // uses Apache commons IO library
}
This example uses the IOUtils class from Apache commons-io library.
If you are targeting Java 9+ you can alternatively use data = in.readAllBytes();
.