java.util.zip.ZipError Java Examples
The following examples show how to use
java.util.zip.ZipError.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZipFileSystemProvider.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #2
Source File: ZipFileSystemProvider.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #3
Source File: ZipFileSystemProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #4
Source File: ZipFileSystemProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #5
Source File: ZipFileSystemProvider.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #6
Source File: ZipFileSystemProvider.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #7
Source File: ZipFileSystemProvider.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #8
Source File: ZipFileSystemProvider.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #9
Source File: ZipFileSystemProvider.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #10
Source File: ZipFileSystemProvider.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #11
Source File: ZipFileSystemProvider.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #12
Source File: ZipFileSystemProvider.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #13
Source File: ZipFileSystemProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #14
Source File: ZipFileSystemProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #15
Source File: ZipFileSystemProvider.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #16
Source File: ZipFileSystemProvider.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #17
Source File: Unzip.java From buck with Apache License 2.0 | 6 votes |
/** * Gets a set of files that are contained in an archive * * @param archiveAbsolutePath The absolute path to the archive * @return A set of files (not directories) that are contained in the zip file * @throws IOException If there is an error reading the archive */ public static ImmutableSet<Path> getZipMembers(Path archiveAbsolutePath) throws IOException { try (FileSystem zipFs = FileSystems.newFileSystem(archiveAbsolutePath, null)) { Path root = Iterables.getOnlyElement(zipFs.getRootDirectories()); return Files.walk(root) .filter(path -> !Files.isDirectory(path)) .map(root::relativize) .map(path -> Paths.get(path.toString())) // Clear the filesystem from the path .collect(ImmutableSet.toImmutableSet()); } catch (ZipError error) { // For some reason the zip filesystem support throws an error when an IOException would do // just as well. throw new IOException( String.format("Could not read %s because of %s", archiveAbsolutePath, error.toString()), error); } }
Example #18
Source File: ZipFileSystemProvider.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #19
Source File: ZipFileSystemProvider.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #20
Source File: ZipFileSystemProvider.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #21
Source File: ZipFileSystemProvider.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #22
Source File: ZipFileSystemProvider.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #23
Source File: ZipFileSystemProvider.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #24
Source File: ZipUtils.java From quarkus with Apache License 2.0 | 6 votes |
public static void unzip(Path zipFile, Path targetDir) throws IOException { try { if (!Files.exists(targetDir)) { Files.createDirectories(targetDir); } } catch (FileAlreadyExistsException fae) { throw new IOException("Could not create directory '" + targetDir + "' as a file already exists with the same name"); } try (FileSystem zipfs = newFileSystem(zipFile)) { for (Path zipRoot : zipfs.getRootDirectories()) { copyFromZip(zipRoot, targetDir); } } catch (IOException | ZipError ioe) { // TODO: (at a later date) Get rid of the ZipError catching (and instead only catch IOException) // since it's a JDK bug which threw the undeclared ZipError instead of an IOException. // Java 9 fixes it https://bugs.openjdk.java.net/browse/JDK-8062754 throw new IOException("Could not unzip " + zipFile + " to target dir " + targetDir, ioe); } }
Example #25
Source File: ZipUtils.java From quarkus with Apache License 2.0 | 6 votes |
/** * This call is not thread safe, a single of FileSystem can be created for the * profided uri until it is closed. * * @param uri The uri to the zip file. * @param env Env map. * @return A new FileSystem. * @throws IOException in case of a failure */ public static FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { // If Multi threading required, logic should be added to wrap this fs // onto a fs that handles a reference counter and close the fs only when all thread are done // with it. try { return FileSystems.newFileSystem(uri, env); } catch (IOException | ZipError ioe) { // TODO: (at a later date) Get rid of the ZipError catching (and instead only catch IOException) // since it's a JDK bug which threw the undeclared ZipError instead of an IOException. // Java 9 fixes it https://bugs.openjdk.java.net/browse/JDK-8062754 // include the URI for which the filesystem creation failed throw new IOException("Failed to create a new filesystem for " + uri, ioe); } }
Example #26
Source File: ZipFileSystemProvider.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException { Path path = uriToPath(uri); synchronized(filesystems) { Path realPath = null; if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ZipFileSystem zipfs = null; try { zipfs = new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; // assume NOT a zip/jar file throw new UnsupportedOperationException(); } filesystems.put(realPath, zipfs); return zipfs; } }
Example #27
Source File: ZipFileSystemProvider.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } ensureFile(path); try { return new ZipFileSystem(this, path, env); } catch (ZipError ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } }
Example #28
Source File: ZipUtils.java From quarkus with Apache License 2.0 | 5 votes |
/** * This call is thread safe, a new FS is created for each invocation. * * @param path The zip file. * @return A new FileSystem instance * @throws IOException in case of a failure */ public static FileSystem newFileSystem(final Path path) throws IOException { try { return FileSystems.newFileSystem(path, (ClassLoader) null); } catch (IOException | ZipError ioe) { // TODO: (at a later date) Get rid of the ZipError catching (and instead only catch IOException) // since it's a JDK bug which threw the undeclared ZipError instead of an IOException. // Java 9 fixes it https://bugs.openjdk.java.net/browse/JDK-8062754 // include the path for which the filesystem creation failed throw new IOException("Failed to create a new filesystem for " + path, ioe); } }
Example #29
Source File: ZipFileSystem.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
static void zerror(String msg) { throw new ZipError(msg); }
Example #30
Source File: ZipFileSystem.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
static void zerror(String msg) { throw new ZipError(msg); }