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

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


            return name;
        }
       
        public LineIterator getEntries() throws IOException {
            if(name.endsWith(".zip")){
                ZipArchiveInputStream zipIn = new ZipArchiveInputStream(is);
                zipIn.getNextEntry();
                return IOUtils.lineIterator(zipIn, "UTF-8");
            } else {
                return IOUtils.lineIterator(is, "UTF-8");
            }
        }
View Full Code Here


        } else if ("bz2".equalsIgnoreCase(FilenameUtils.getExtension(name))) {
            is = new BZip2CompressorInputStream(is);
            name = FilenameUtils.removeExtension(name);
            log.debug("   - from BZip2 Archive");
        } else if ("zip".equalsIgnoreCase(FilenameUtils.getExtension(name))) {
            ZipArchiveInputStream zipin = new ZipArchiveInputStream(is);
            ArchiveEntry entry = zipin.getNextEntry();
            log.info("For ZIP archives only the 1st Entry will be processed!");
            name = FilenameUtils.getName(entry.getName());
            log.info("  - processed Entry: {}",entry.getName());
        } else { // else uncompressed data ...
            log.info("  - uncompressed source: {}",name);
View Full Code Here

            throw new LDPathException(msg, e);
        }

        try {
            InputStream is = getSolrTemplateStream();
            ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
            ZipArchiveEntry ze = null;
            byte[] schemaFile = null;
            while ((ze = zis.getNextZipEntry()) != null) {
                if (SOLR_TEMPLATE_SCHEMA.equals(ze.getName())) {
                    schemaFile = createSchemaXML(getLDPathProgram(ldPathProgram), IOUtils.toByteArray(zis));
                    TarArchiveEntry te = new TarArchiveEntry(coreName + SOLR_SCHEMA);
                    te.setSize(schemaFile.length);
                    tarOutputStream.putArchiveEntry(te);
View Full Code Here

        } else {
            archiveFormat = SUPPORTED_SOLR_ARCHIVE_FORMAT.get(solrArchiveExtension);
        }
        ArchiveInputStream ais;
        if ("zip".equals(archiveFormat)) {
            ais = new ZipArchiveInputStream(is);
        } else {
            if ("gz".equals(archiveFormat)) {
                is = new GZIPInputStream(is);
            } else if ("bz2".equals(archiveFormat)) {
                is = new BZip2CompressorInputStream(is);
View Full Code Here

        extract(new TarArchiveInputStream(new FileInputStream(uncompressedFile)), targetFolder);
        FileUtils.forceDelete(uncompressedFile);
    }

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

        } else if (a == 0x1f && b == 0x8b) {
            metadata.set(Metadata.CONTENT_TYPE, "application/x-gzip");
            decompress(new GZIPInputStream(stream), xhtml);
        } else if (a == 'P' && b == 'K') {
            metadata.set(Metadata.CONTENT_TYPE, "application/zip");
            unpack(new ZipArchiveInputStream(stream), xhtml);
        } else if ((a == '0' && b == '7')
                || (a == 0x71 && b == 0xc7)
                || (a == 0xc7 && b == 0x71)) {
            metadata.set(Metadata.CONTENT_TYPE, "application/x-cpio");
            unpack(new CpioArchiveInputStream(stream), xhtml);
View Full Code Here

        return supportedTypes;
    }

    public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context)
            throws IOException, SAXException, TikaException {
        ZipArchiveInputStream zip = new ZipArchiveInputStream(stream);
        ZipArchiveEntry entry = zip.getNextZipEntry();

        while (entry != null) {
            if (!IWORK_CONTENT_ENTRIES.contains(entry.getName())) {
                entry = zip.getNextZipEntry();
                continue;
            }

            InputStream entryStream = new BufferedInputStream(zip, 4096);
            entryStream.mark(4096);
            IWORKDocumentType type = IWORKDocumentType.detectType(entryStream);
            entryStream.reset();
           
            if(type != null) {
               XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
               ContentHandler contentHandler;
              
               switch(type) {
               case KEYNOTE:
                  contentHandler = new KeynoteContentHandler(xhtml, metadata);
                  break;
               case NUMBERS:
                  contentHandler = new NumbersContentHandler(xhtml, metadata);
                  break;
               case PAGES:
                  contentHandler = new PagesContentHandler(xhtml, metadata);
                  break;
               default:
                  throw new TikaException("Unhandled iWorks file " + type);
               }

               metadata.add(Metadata.CONTENT_TYPE, type.getType().toString());
               xhtml.startDocument();
               context.getSAXParser().parse(
                       new CloseShieldInputStream(entryStream),
                       new OfflineContentHandler(contentHandler)
               );
               xhtml.endDocument();
            }
           
            entry = zip.getNextZipEntry();
        }
        zip.close();
    }
View Full Code Here

     * @param encoding the encoding of the entry names
     */
    public ArchiveInputStream getArchiveStream(InputStream stream,
                                               String encoding)
        throws IOException {
        return new ZipArchiveInputStream(stream, encoding, true);
    }
View Full Code Here

                input = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(file)));
            } catch (IOException e) {
                try {
                    input = new TarArchiveInputStream(new BZip2CompressorInputStream(new FileInputStream(file)));
                } catch (IOException e2) {
                    input = new ZipArchiveInputStream(new FileInputStream(file));
                }
            }

            ArchiveEntry entry = input.getNextEntry();
            while (entry != null) {
View Full Code Here

            throw new IllegalArgumentException("The parsed poading dictionary MUST NOT be NULL");
        }
        if(paodingDict.isFile()){
            throw new IllegalArgumentException("The parsed paoding dictionary MUST NOT be a File");
        }
        ZipArchiveInputStream zin = new ZipArchiveInputStream(in);
        ZipArchiveEntry entry;
        try {
            while((entry = zin.getNextZipEntry()) != null){
                if(!entry.isDirectory()){
                    File file = new File(paodingDict,entry.getName());
                    if(!file.isFile()){
                        //copy the entry
                        log.debug("   > copy {}",entry.getName());
View Full Code Here

TOP

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

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.