As vbezhenear said, and as I myself experimented, the JarURLConnection notation in the form c:/testfs/my-outer.jar!/my-inner.jar does not seem to be implemented by the factory FileSystems.newFileSystem(Path path, ClassLoader loader) .
But you can still access the internal bank as follows:
Path outerPath = Paths.get("c:/testfs/my-outer.jar"); try (FileSystem outerFS = FileSystems.newFileSystem(outerPath, null)) { Path innerPath = outerFS.getPath("/my-inner.jar"); try (FileSystem innerFS = FileSystems.newFileSystem(innerPath, null)) { ... } }
- UPDATE -
If you are trying to use a URI instead of Path , you can create a ZipFileSystem , like this
URI uri = URI.create("jar:file:/home/orto/stackoverflow/outer.jar!/inner.jar"); Map<String,String> env = Collections.emptyMap(); try(ZipFileSystem zipfs = (ZipFileSystem)FileSystems.newFileSystem(uri,env)) {...}
But you will not be able to access outer.jar , not inner.jar
If you look at the source code of the JarFileSystemProvider , you will see
@Override protected Path uriToPath(URI uri) { String scheme = uri.getScheme(); if ((scheme == null) || !scheme.equalsIgnoreCase(getScheme())) { throw new IllegalArgumentException("URI scheme is not '" + getScheme() + "'"); } try { String uristr = uri.toString(); int end = uristr.indexOf("!/"); uristr = uristr.substring(4, (end == -1) ? uristr.length() : end); uri = new URI(uristr); return Paths.get(new URI("file", uri.getHost(), uri.getPath(), null)) .toAbsolutePath(); } catch (URISyntaxException e) { throw new AssertionError(e);
The path is cut to the first "!" . Thus, there is no way to directly create a file system in the internal panel from the newFileSystem method.
source share