How do I construct a
Paths tries to resolve a
FileSystem which would contain your
Path. (Actually this may be an implementation detail. The spec simply states that it will check the default
FileSystem.) If you haven't registered/created such a
FileSystem, it won't be able to find it.
You would create a new
FileSystem from the jar file and access the entry
Path through that
Path path = Paths.get("C:/foo.jar"); URI uri = new URI("jar", path.toUri().toString(), null); Map<String, String> env = new HashMap<>(); env.put("create", "true"); FileSystem fileSystem = FileSystems.newFileSystem(uri, env); Path file = fileSystem.getPath("bar.html"); System.out.println(file);
You could then use
Be careful to properly close the
FileSystem when finished using it.
For more information about ZipFileSystemProvider, see here.