Package java.util.zip

Examples of java.util.zip.ZipException


            return name.getBytes();
        } else {
            try {
                return name.getBytes(encoding);
            } catch (UnsupportedEncodingException uee) {
                throw new ZipException(uee.getMessage());
            }
        }
    }
View Full Code Here


        System.arraycopy(data, offset + 4, tmp, 0, length - 4);
        crc.reset();
        crc.update(tmp);
        long realChecksum = crc.getValue();
        if (givenChecksum != realChecksum) {
            throw new ZipException("bad CRC checksum "
                                   + Long.toHexString(givenChecksum)
                                   + " instead of "
                                   + Long.toHexString(realChecksum));
        }
View Full Code Here

                return bis;
            case ZipEntry.DEFLATED:
                bis.addDummy();
                return new InflaterInputStream(bis, new Inflater(true));
            default:
                throw new ZipException("Found unsupported compression method "
                                       + ze.getMethod());
        }
    }
View Full Code Here

            }
            archive.seek(--off);
            curr = archive.read();
        }
        if (!found) {
            throw new ZipException("archive is not a ZIP archive");
        }
        archive.seek(off + CFD_LOCATOR_OFFSET);
        byte[] cfdOffset = new byte[4];
        archive.readFully(cfdOffset);
        archive.seek((new ZipLong(cfdOffset)).getValue());
View Full Code Here

            return new String(bytes);
        } else {
            try {
                return new String(bytes, encoding);
            } catch (UnsupportedEncodingException uee) {
                throw new ZipException(uee.getMessage());
            }
        }
    }
View Full Code Here

    return this.workspaceScope;
  }

  public void verifyArchiveContent(IPath path) throws CoreException {
    if (isInvalidArchive(path)) {
      throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException()));     
    }
    ZipFile file = getZipFile(path);
    closeZipFile(file);
  }
View Full Code Here

   * @exception CoreException If unable to create/open the ZipFile
   */
  public ZipFile getZipFile(IPath path) throws CoreException {

    if (isInvalidArchive(path))
      throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException()));
   
    ZipCache zipCache;
    ZipFile zipFile;
    if ((zipCache = (ZipCache)this.zipFiles.get()) != null
        && (zipFile = zipCache.getCache(path)) != null) {
View Full Code Here

            if (buffer.getInt(pos) == ENDSIG) {
                break;
            }
        }
        if (pos < 0) {
            throw new ZipException(
                "central directory not found, probably not a zip file");
        }

        final int count = buffer.getShort(pos + ENDTOT);
//        System.out.println("Count=" + count);
        final int centralOffset = buffer.getInt(pos + ENDOFF);
//        System.out.println("centralOffset=" + centralOffset);

        HashMap<String, ByteBuffer> entries = new HashMap<String, ByteBuffer>(
            count + count / 2);
        buffer.position(centralOffset);

        byte[] strBuf = new byte[16];
        for (int i = 0; i < count; i++) {
            pos = buffer.position();
            buffer.position(buffer.position() + CENHDR);

            if (buffer.getInt(pos + 0) != CENSIG) {
                throw new ZipException("Wrong Central Directory signature "
                    + NumberUtils.hex(buffer.getInt(pos + 0)));
            }

            int method = buffer.getShort(pos + CENHOW);
            int dostime = buffer.getInt(pos + CENTIM);
View Full Code Here

    private int checkLocalHeader(ByteBuffer buffer, int offset, int method)
        throws IOException {

        if (buffer.getInt(offset + 0) != LOCSIG) {
            throw new ZipException("Wrong Local header signature");
        }

        if (method != buffer.getShort(offset + LOCHOW)) {
            throw new ZipException("Compression method mismatch");
        }

        final int nameLen = buffer.getShort(offset + LOCNAM);
        final int extraLen = buffer.getShort(offset + LOCEXT);
        return offset + LOCHDR + nameLen + extraLen;
View Full Code Here

    {
        CBJarResource resourceFile = getJarContainingResource(resourceName);
        if (resourceFile != null)
            return resourceFile.getInputStream(resourceName);

        throw new ZipException("File: '" + resourceName + "' not found");
    }
View Full Code Here

TOP

Related Classes of java.util.zip.ZipException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.