Am trying to customize extent report using config.xml file. All works fine when running from eclipse. I have my config.xml inside resources folder. However, when I export as runnable JAR file, the code fails with NPE as it couldnt' find the config.xml file. I have tried various options and also tried writing to temp file as shown below.
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
InputStream resource = classLoader.getClass().getResourceAsStream(extentfileName);
final File tempFile = File.createTempFile("extent-config", ".xml", new File("./"));
System.out.println(tempFile.getAbsolutePath());
tempFile.deleteOnExit();
try (FileOutputStream out = new FileOutputStream(tempFile)) {
IOUtils.copy(resource, out);}
In the above code, tempfile is created but has no contents. any help is highly appreciated