if (protocol.equals("jar")) {
String path = url.getPath();
int pos = path.lastIndexOf("!/");
URL nested = new URL(path.substring(0, pos));
if (nested.getProtocol().equals("file")) {
return new JarFileSystem(url);
} else {
throw new IOException("Cannot handle nested jar URL " + url);
}
} else if (protocol.equals("file")) {
File f;
try {
f = new File(url.toURI());
}
catch (URISyntaxException e) {
throw new IOException(e);
}
if (f.isDirectory()) {
return new DiskFileSystem(f);
} else {
return new JarFileSystem(url);
}
} else {
throw new IOException("Unsupported URL: " + url);
}
}