- Common ways to obtain MountableFile
private void myMethod () {MountableFile m =
String resourceName;MountableFile.forClasspathResource(resourceName)
- Smart code suggestions by Codota
}
deleteOnExit(tmpLocation.toPath());
@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()) { // Create parent directories 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; } } }