类java.util.zip.ZipError源码实例Demo

下面列出了怎么用java.util.zip.ZipError的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码2 项目: dragonwell8_jdk   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码3 项目: TencentKona-8   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码4 项目: TencentKona-8   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码5 项目: jdk8u60   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码6 项目: jdk8u60   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码7 项目: quarkus   文件: ZipUtils.java
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);
    }
}
 
源代码8 项目: quarkus   文件: ZipUtils.java
/**
 * 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);
    }
}
 
源代码9 项目: openjdk-jdk8u   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码10 项目: openjdk-jdk8u   文件: ZipFileSystemProvider.java
@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();
    }
}
 
@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;
    }
}
 
@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();
    }
}
 
源代码13 项目: jdk8u-jdk   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码14 项目: jdk8u-jdk   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码15 项目: hottub   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码16 项目: hottub   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码17 项目: openjdk-8-source   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码18 项目: openjdk-8-source   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码19 项目: openjdk-8   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码20 项目: openjdk-8   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码21 项目: jdk8u_jdk   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码22 项目: jdk8u_jdk   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码23 项目: jdk8u-jdk   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码24 项目: jdk8u-jdk   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码25 项目: jdk8u-dev-jdk   文件: ZipFileSystemProvider.java
@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;
    }
}
 
源代码26 项目: jdk8u-dev-jdk   文件: ZipFileSystemProvider.java
@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();
    }
}
 
源代码27 项目: buck   文件: Unzip.java
/**
 * 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);
  }
}
 
源代码28 项目: quarkus   文件: ZipUtils.java
/**
 * 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);
    }
}
 
源代码29 项目: dragonwell8_jdk   文件: ZipFileSystem.java
static void zerror(String msg) {
    throw new ZipError(msg);
}
 
源代码30 项目: TencentKona-8   文件: ZipFileSystem.java
static void zerror(String msg) {
    throw new ZipError(msg);
}
 
 类所在包
 同包方法