Java InputStream Copy copyStream(ZipInputStream in, ZipEntry entry)

Here you can find the source of copyStream(ZipInputStream in, ZipEntry entry)

Description

copy Stream

License

Open Source License

Declaration

protected static byte[] copyStream(ZipInputStream in, ZipEntry entry)
            throws Exception 

Method Source Code

//package com.java2s;
/**/*from   ww w . ja v  a2  s .com*/
 * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompany this distribution.
 *
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * The Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 * Bosch Software Innovations GmbH - Please refer to git log
 */

import java.io.BufferedOutputStream;

import java.io.ByteArrayOutputStream;

import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
    protected static byte[] copyStream(ZipInputStream in, ZipEntry entry)
            throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        int size;
        byte[] buffer = new byte[2048];

        BufferedOutputStream bos = new BufferedOutputStream(out);

        while ((size = in.read(buffer, 0, buffer.length)) != -1) {
            bos.write(buffer, 0, size);
        }
        bos.flush();
        bos.close();
        return out.toByteArray();
    }
}

Related

  1. copyStream(InputStream is)
  2. copyStream(InputStream iss)
  3. copyStream(Reader in, Writer out)
  4. copyStream(Reader in, Writer out)
  5. copyStream(Reader reader, Writer writer)
  6. copyStreamBytes(InputStream is)
  7. copyStreamToByteArray(InputStream in, byte[] dest, int off, int len)
  8. copyStreamToBytes(InputStream inputStream)
  9. copyStreamToString(InputStream input)