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

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


  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


  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

  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

  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

  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

    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

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

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

    Map<String, String> data = readArchive(zip);
    assertEquals(XSL_IMAGE1_MD5, data.get("0.jpg"));
    assertEquals(XSL_IMAGE2_MD5, data.get("1.jpg"));
View Full Code Here

    Response response = WebClient.create(endPoint + ALL_PATH)
        .header(CONTENT_TYPE, APPLICATION_XML)
        .accept("application/zip")
        .put(ClassLoader.getSystemResourceAsStream("test.doc"));

    String responseMsg = readArchiveText(new ZipArchiveInputStream(
        (InputStream) response.getEntity()));
    assertNotNull(responseMsg);
    assertTrue(responseMsg.contains("test"));
  }
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

    LOG.info(String.format("Unzipping %s to dir %s.", inputFile
        .getAbsolutePath(), outputDir.getAbsolutePath()));

    final List<File> unzippedFiles = new LinkedList<File>();
    final InputStream is = new FileInputStream(inputFile);
    final ZipArchiveInputStream debInputStream = (ZipArchiveInputStream) new ArchiveStreamFactory()
        .createArchiveInputStream("zip", is);
    ZipArchiveEntry entry = null;
    while ((entry = (ZipArchiveEntry) debInputStream.getNextEntry()) != null) {
      final File outputFile = new File(outputDir, entry.getName());
      if (entry.isDirectory()) {
        LOG.info(String.format(
            "Attempting to write output directory %s.", outputFile
                .getAbsolutePath()));
        if (!outputFile.exists()) {
          LOG.info(String.format(
              "Attempting to create output directory %s.",
              outputFile.getAbsolutePath()));
          if (!outputFile.mkdirs()) {
            throw new IllegalStateException(String.format(
                "Couldn't create directory %s.", outputFile
                    .getAbsolutePath()));
          }
        }
      } else {
        LOG.info(String.format("Creating output file %s.", outputFile
            .getAbsolutePath()));
        File parent = outputFile.getParentFile();
        if (!parent.exists()) {
          LOG
              .info(String
                  .format(
                      "Got a file entry before the parent directory entry."
                          + " Attempting to create the parent directory directory %s.",
                      parent.getAbsolutePath()));
          if (!parent.mkdirs()) {
            throw new IllegalStateException(String.format(
                "Couldn't create directory %s.", parent
                    .getAbsolutePath()));
          }
        }
        outputFile.createNewFile();
        final OutputStream outputFileStream = new FileOutputStream(
            outputFile);
        IOUtils.copy(debInputStream, outputFileStream);
        outputFileStream.close();
      }
      unzippedFiles.add(outputFile);
    }
    debInputStream.close();
    return unzippedFiles;
  }
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.