@SuppressWarnings("ResultOfMethodCallIgnored")
private void copyFromJarToLocation(final JarFile jarFile, final JarEntry entry, final String fromRoot, final File toRoot) throws IOException {
String destinationName = entry.getName().replaceFirst(fromRoot, "");
File newFile = new File(toRoot, destinationName);
log.debug("Copying resource {} from JAR file {}", fromRoot, jarFile.getName());
if (!entry.isDirectory()) {
Path parent = newFile.getAbsoluteFile().toPath().getParent();
parent.toFile().mkdirs();
newFile.deleteOnExit();
try (InputStream is = jarFile.getInputStream(entry)) {
Files.copy(is, newFile.toPath());
} catch (IOException e) {
log.error("Failed to extract classpath resource " + entry.getName() + " from JAR file " + jarFile.getName(), e);
throw e;
}
}
}