in src/main/java/org/apache/sling/feature/io/IOUtils.java [179:217]
public static File getFileFromURL(URL url, boolean cache, File tmpDir) throws IOException {
File result;
if (url.getProtocol().equals("file")) {
try {
result = new File(url.toURI());
} catch (URISyntaxException e) {
result = new File(url.getPath());
}
} else if (url.getProtocol().equals("jar")) {
String innerURL = url.getPath();
if (innerURL.endsWith("!/") && innerURL.indexOf("!/") == innerURL.lastIndexOf("!/")) {
innerURL = innerURL.substring(0, innerURL.indexOf("!/"));
try {
result = getFileFromURL(new URL(innerURL), cache, tmpDir);
} catch (IOException ex) {
result = null;
}
}
else {
result = null;
}
}
else {
result = null;
}
if ((result == null || !result.exists()) && cache) {
File tmp = File.createTempFile("jar", ".jar", tmpDir);
tmp.deleteOnExit();
try (InputStream input = url.openStream(); OutputStream output = new FileOutputStream(tmp)) {
byte[] buffer =new byte[64 * 1024];
for (int i = input.read(buffer); i != -1;i = input.read(buffer)) {
output.write(buffer, 0, i);
}
}
result = tmp;
}
return result;
}