Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You found a bug in the implementation/documentation of the zipfs.The documentation of the Path.get methods states:</p> <pre><code>* @throws FileSystemNotFoundException * The file system, identified by the URI, does not exist and * cannot be created automatically </code></pre> <p>edit: In the case of FileSystems that need closing it might be better to require the programmer to call newFileSystem so that he can close it. The documentation should better read "if it should not be created" automatically.</p> <p>ZipFs never tries to create a new filessystem. A failed get() is not caught but passed to be caller before an attempted newFileSystem call. See in the source:</p> <pre><code>public Path getPath(URI uri) { String spec = uri.getSchemeSpecificPart(); int sep = spec.indexOf("!/"); if (sep == -1) throw new IllegalArgumentException("URI: " + uri + " does not contain path info ex. jar:file:/c:/foo.zip!/BAR"); return getFileSystem(uri).getPath(spec.substring(sep + 1)); } </code></pre> <p>In other words:</p> <pre><code>Paths.get() </code></pre> <p>should be enough for all FileSystems based on nio2. With the zipfs design.</p> <pre><code>Path path; try { path = Paths.get( uri ); } catch ( FileSystemNotFoundException exp ) { try( FileSystem fs = FileSystems.newFileSystem( uri, Collections.EMPTY_MAP )) {; path = Paths.get( uri ); ... use path ... } } </code></pre> <p>Is the short form of your workaround.</p> <p>Note: The nio documentation states that the getFileSystem must use/return the FileSystems created by the matching newFileSystem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload