Package org.apache.commons.compress.archivers.zip

Examples of org.apache.commons.compress.archivers.zip.ZipArchiveInputStream


        FileUtils.forceDelete(uncompressedFile);
    }

    private static void extractZipDistribution(URL sourceDistribution, File _targetFolder)
        throws IOException {
        extract(new ZipArchiveInputStream(sourceDistribution.openStream()), _targetFolder);
    }
View Full Code Here


    }

    private void processBillingZipFile(File file, boolean withTags) throws IOException {

        InputStream input = new FileInputStream(file);
        ZipArchiveInputStream zipInput = new ZipArchiveInputStream(input);

        try {
            ArchiveEntry entry;
            while ((entry = zipInput.getNextEntry()) != null) {
                if (entry.isDirectory())
                    continue;

                processBillingFile(entry.getName(), zipInput, withTags);
            }
        }
        catch (IOException e) {
            if (e.getMessage().equals("Stream closed"))
                logger.info("reached end of file.");
            else
                logger.error("Error processing " + file, e);
        }
        finally {
            try {
                zipInput.close();
            } catch (IOException e) {
                logger.error("Error closing " + file, e);
            }
            try {
                input.close();
View Full Code Here

  public void extract( @Nonnull File destination, @Nonnull final InputStream inputStream ) throws IOException {
    if ( !destination.exists() || !destination.isDirectory() ) {
      throw new IllegalArgumentException( "Invalid destination: " + destination.getCanonicalPath() );
    }

    ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream( inputStream );
    try {

      byte[] buf = new byte[BUFFER_LENGTH];
      for ( ArchiveEntry zipEntry = zipInputStream.getNextEntry(); zipEntry != null; zipEntry = zipInputStream.getNextEntry() ) {
        if ( condition != null && !condition.shallExtract( zipEntry ) ) {
          continue;
        }

        String entryName = zipEntry.getName();
        File newFile = new File( destination, entryName );

        //Is a directory
        if ( zipEntry.isDirectory() ) {
          newFile.mkdirs();
          continue;
        }

        //Make the directory structure
        newFile.getParentFile().mkdirs();

        FileOutputStream fileoutputstream = new FileOutputStream( newFile );
        try {
          int n;
          while ( ( n = zipInputStream.read( buf, 0, BUFFER_LENGTH ) ) > -1 ) {
            fileoutputstream.write( buf, 0, n );
          }
        } finally {
          fileoutputstream.close();
        }
      }
    } finally {
      zipInputStream.close();
    }
  }
View Full Code Here

        switch (archiveType){
            case TAR:
                    ais = new TarArchiveInputStream(new FileInputStream(srcFile));
                break;
            case ZIP:
                    ais = new ZipArchiveInputStream(new FileInputStream(srcFile));
                break;
            default:
                throw new IOException("archive type not supported");
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.compress.archivers.zip.ZipArchiveInputStream

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.