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

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


            if (MT_JAVA_ARCHIVE.equals(type)) {
                final ArchiveInputStream archiveStream = new JarArchiveInputStream(bufferedResourceStream);
                importDataArchive(archive, archiveStream, options);
            }
            else if (MediaType.APPLICATION_ZIP.equals(type)) {
                final ArchiveInputStream archiveStream = new ZipArchiveInputStream(bufferedResourceStream);
                importDataArchive(archive, archiveStream, options);
            }
            else if (MT_CPIO.equals(type)) {
                final ArchiveInputStream archiveStream = new CpioArchiveInputStream(bufferedResourceStream);
                importDataArchive(archive, archiveStream, options);
View Full Code Here


  public void extract( @NotNull File destination, @NotNull 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

                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

  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

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.