Examples of ZipArchiveInputStream


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

            newZipStream.closeArchiveEntry();
          } else {
            logger.debug("Adding entries from compressed file...");
            //read the entries from the zip file and copy them to the new zip archive
            //so that we don't have to recompress them.
            ZipArchiveInputStream currentZipStream = new ZipArchiveInputStream(currentFileStream);
            ArchiveEntry currentEntry;
            while ((currentEntry = currentZipStream.getNextEntry()) != null) {
              String entryName = currentEntry.getName();
              logger.debug("Zipping: " + entryName);
              ZipArchiveEntry zipEntry = new ZipArchiveEntry(entryName);
              try {
                newZipStream.putArchiveEntry(zipEntry);
              } catch (Exception e){
                //duplicate names should never happen.
                entryName = Math.round(Math.random() * 10000) + "_" + entryName;
                ZipArchiveEntry zipEntry2 = new ZipArchiveEntry(entryName);
                newZipStream.putArchiveEntry(zipEntry2);
              }
              int bytesRead;
              while ((bytesRead = currentZipStream.read(buffer))!= -1) {
                newZipStream.write(buffer, 0, bytesRead);
                    }
              newZipStream.closeArchiveEntry();
            }
            currentZipStream.close();
         
        } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
View Full Code Here

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

                                                       Path appPath,
                                                       String entry)
      throws IOException {
    InputStream is = null;
    FSDataInputStream appStream = fs.open(appPath);
    ZipArchiveInputStream zis = new ZipArchiveInputStream(appStream);
    ZipArchiveEntry zipEntry;
    boolean done = false;
    while (!done && (zipEntry = zis.getNextZipEntry()) != null) {
      if (entry.equals(zipEntry.getName())) {
        int size = (int) zipEntry.getSize();
        byte[] content = new byte[size];
        int offset = 0;
        while (offset < size) {
          offset += zis.read(content, offset, size - offset);
        }
        is = new ByteArrayInputStream(content);
        done = true;
      }
    }
View Full Code Here

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

                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

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

        } 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

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

  public void testDocWAV() throws Exception {
    Response response = WebClient.create(endPoint + UNPACKER_PATH)
        .type(APPLICATION_MSWORD).accept("application/zip")
        .put(ClassLoader.getSystemResourceAsStream(TEST_DOC_WAV));

    ArchiveInputStream zip = new ZipArchiveInputStream(
        (InputStream) response.getEntity());

    Map<String, String> data = readArchive(zip);
    assertEquals(WAV1_MD5, data.get(WAV1_NAME));
    assertEquals(WAV2_MD5, data.get(WAV2_NAME));
View Full Code Here

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

  public void testDocWAVText() throws Exception {
    Response response = WebClient.create(endPoint + ALL_PATH)
        .type(APPLICATION_MSWORD).accept("application/zip")
        .put(ClassLoader.getSystemResourceAsStream(TEST_DOC_WAV));

    ArchiveInputStream zip = new ZipArchiveInputStream(
        (InputStream) response.getEntity());

    Map<String, String> data = readArchive(zip);
    assertEquals(WAV1_MD5, data.get(WAV1_NAME));
    assertEquals(WAV2_MD5, data.get(WAV2_NAME));
View Full Code Here

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

  public void testDocPicture() throws Exception {
    Response response = WebClient.create(endPoint + UNPACKER_PATH)
        .type(APPLICATION_MSWORD).accept("application/zip")
        .put(ClassLoader.getSystemResourceAsStream(TEST_DOC_WAV));

    ZipArchiveInputStream zip = new ZipArchiveInputStream(
        (InputStream) response.getEntity());
    Map<String, String> data = readArchive(zip);

    assertEquals(JPG_MD5, data.get(JPG_NAME));
  }
View Full Code Here

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

  public void testDocPictureNoOle() throws Exception {
    Response response = WebClient.create(endPoint + UNPACKER_PATH)
        .type(APPLICATION_MSWORD).accept("application/zip")
        .put(ClassLoader.getSystemResourceAsStream("2pic.doc"));

    ZipArchiveInputStream zip = new ZipArchiveInputStream(
        (InputStream) response.getEntity());

    Map<String, String> data = readArchive(zip);
    assertEquals(JPG2_MD5, data.get(JPG2_NAME));
  }
View Full Code Here

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

  public void testImageDOCX() throws Exception {
    Response response = WebClient.create(endPoint + UNPACKER_PATH)
    .accept("application/zip").put(
        ClassLoader.getSystemResourceAsStream(TEST_DOCX_IMAGE));

    ZipArchiveInputStream zip = new ZipArchiveInputStream(
        (InputStream) response.getEntity());

    Map<String, String> data = readArchive(zip);
    assertEquals(DOCX_IMAGE1_MD5, data.get(DOCX_IMAGE1_NAME));
    assertEquals(DOCX_IMAGE2_MD5, data.get(DOCX_IMAGE2_NAME));
View Full Code Here

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

    String TEST_DOCX_EXE = "2exe.docx";
    Response response = WebClient.create(endPoint + UNPACKER_PATH)
        .accept("application/zip")
        .put(ClassLoader.getSystemResourceAsStream(TEST_DOCX_EXE));

    ZipArchiveInputStream zip = new ZipArchiveInputStream(
        (InputStream) response.getEntity());

    Map<String, String> data = readArchive(zip);

    assertEquals(DOCX_EXE1_MD5, data.get(DOCX_EXE1_NAME));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.