Package java.util.zip

Examples of java.util.zip.ZipEntry


      zis = new ZipInputStream(
          new BufferedInputStream( new FileInputStream( contents ) ));
       
      while( true ){
       
        ZipEntry  entry = zis.getNextEntry();
         
        if ( entry == null ){
         
          break;
        }
       
        String  name = entry.getName();
       
        int pos = name.indexOf( resource_name + "/" );
       
        if ( pos != -1 ){
                   
View Full Code Here


  private boolean readData(final InputStream in)
  {
    try
    {
      final ZipInputStream iconJar = new ZipInputStream(in);
      ZipEntry ze = iconJar.getNextEntry();
      while (ze != null)
      {
        final String fullName = ze.getName();
        if (fullName.endsWith(".gif"))
        {
          final String category = getCategory(fullName);
          final String name = getName(fullName);
          final Image image = getImage(iconJar);
          final Long bytes = new Long(ze.getSize());
          //logger.debug ("Add Icon: " + name);
          addIconEntry(name, category, image, bytes);
        }
        iconJar.closeEntry();
        ze = iconJar.getNextEntry();
View Full Code Here

    if (data instanceof byte[] == false)
    {
      throw new ContentIOException("No such repository");
    }
    final ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream((byte[]) data));
    ZipEntry ze = zin.getNextEntry();
    while (ze != null)
    {
      final String fullName = ze.getName();
      if (fullName.equals(fileName) == false)
      {
        zin.closeEntry();
        ze = zin.getNextEntry();
        continue;
      }

      response.setContentLength((int) ze.getSize());

      final String contextMimeType = getServletContext().getMimeType(fileName);
      if (contextMimeType != null)
      {
        response.setContentType(contextMimeType);
View Full Code Here

  /* (non-Javadoc)
   * @see it.unimi.dsi.mg4j.document.DocumentCollectionBuilder#startDocument(java.lang.CharSequence, java.lang.CharSequence)
   */
 
  public void startDocument( final CharSequence title, final CharSequence uri ) throws IOException {
    final ZipEntry currEntry = new ZipEntry( Integer.toString( numberOfDocuments ) );
    currEntry.setComment( title.toString() );
    zipOut.putNextEntry( currEntry );
    new MutableString( uri != null ? uri : "" ).writeSelfDelimUTF8( zipOut );
   
  }
View Full Code Here

  /* (non-Javadoc)
   * @see it.unimi.dsi.mg4j.document.DocumentCollectionBuilder#close()
   */
 
  public void close() throws IOException {
    if ( numberOfDocuments == 0 ) zipOut.putNextEntry( new ZipEntry( "dummy" ) );
    zipDataOutputStream.close();
    final ZipDocumentCollection zipDocumentCollection = new ZipDocumentCollection( basenameSuffix + ZipDocumentCollection.ZIP_EXTENSION, factory, numberOfDocuments, exact );
    BinIO.storeObject( zipDocumentCollection, basenameSuffix + DocumentCollection.DEFAULT_EXTENSION );
    zipDocumentCollection.close();
  }
View Full Code Here

            in = IOUtils.openFileInputStream(fileName);
            ZipInputStream zipIn = new ZipInputStream(in);
            String originalDbName = null;
            boolean multiple = false;
            while (true) {
                ZipEntry entry = zipIn.getNextEntry();
                if (entry == null) {
                    break;
                }
                String entryName = entry.getName();
                zipIn.closeEntry();
                String name = getDatabaseNameFromFileName(entryName);
                if (name != null) {
                    if (db.equals(name)) {
                        originalDbName = name;
View Full Code Here

                originalDbLen = originalDbName.length();
            }
            in = IOUtils.openFileInputStream(zipFileName);
            ZipInputStream zipIn = new ZipInputStream(in);
            while (true) {
                ZipEntry entry = zipIn.getNextEntry();
                if (entry == null) {
                    break;
                }
                String fileName = entry.getName();
                // restoring windows backups on linux and vice versa
                fileName = fileName.replace('\\', SysProperties.FILE_SEPARATOR.charAt(0));
                fileName = fileName.replace('/', SysProperties.FILE_SEPARATOR.charAt(0));
                if (fileName.startsWith(SysProperties.FILE_SEPARATOR)) {
                    fileName = fileName.substring(1);
View Full Code Here

            return IOUtils.readBytesAndClose(in, 0);
        }
        ZipInputStream zipIn = new ZipInputStream(in);
        try {
            while (true) {
                ZipEntry entry = zipIn.getNextEntry();
                if (entry == null) {
                    break;
                }
                String entryName = entry.getName();
                if (!entryName.startsWith("/")) {
                    entryName = "/" + entryName;
                }
                if (entryName.equals(name)) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

                                        String entryName) {

        try {

            long size = fromFile.length();
            ZipEntry zEntry = new ZipEntry(entryName);
            zEntry.setSize(size);
            zEntry.setCrc(0);// Don't know what it these values are
            // right now, but zero works...
            zoStream.putNextEntry(zEntry);

            FileInputStream fis = new FileInputStream(fromFile);

            byte[] bytes = new byte[1024];

            int numRead;
            CRC32 checksum = new CRC32();
            while ((numRead = fis.read(bytes)) > 0) {
                zoStream.write(bytes, 0, numRead);
                checksum.update(bytes, 0, numRead);
            }
            zEntry.setCrc(checksum.getValue());

            fis.close();
            zoStream.closeEntry();

        } catch (IOException ioe) {
View Full Code Here

                    if (Debug.debugging("zip")) {
                        Debug.output(" unzipping " + zipFileName);
                    }
                    ZipInputStream zin = new ZipInputStream(in);
                    ZipEntry e;

                    while ((e = zin.getNextEntry()) != null) {

                        if (e.isDirectory()) {
                            new File(toDir, e.getName()).mkdirs();
                        } else {
                            if (Debug.debugging("zip")) {
                                Debug.output(" unzipping " + e.getName());
                            }
                            unzip(zin, new File(toDir, e.getName()));
                        }
                    }
                    zin.close();
                    if (deleteAfter) {
                        if (Debug.debugging("zip")) {
                            Debug.output("unzipping complete, deleting zip file");
                        }

                        File file = new File(zipurl.getFile());
                        if (file.exists()) {
                            file.delete();
                        }
                    } else if (Debug.debugging("zip")) {
                        Debug.output("unzipping complete, leaving zip file");
                    }
                    return;
                }
            } catch (FileNotFoundException e1) {
                e1.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
View Full Code Here

TOP

Related Classes of java.util.zip.ZipEntry

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.