Here you can find the source of getResourcesFromZip(final byte[] barContent)
public static Map<String, byte[]> getResourcesFromZip(final byte[] barContent) throws IOException
//package com.java2s; /**/*from ww w. j ava2s . c o m*/ * Copyright (C) 2011 BonitaSoft S.A. * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2.0 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static Map<String, byte[]> getResourcesFromZip(final byte[] barContent) throws IOException { final Map<String, byte[]> resources = new HashMap<String, byte[]>(); final InputStream in = new ByteArrayInputStream(barContent); final ZipInputStream zis = new ZipInputStream(in); ZipEntry zipEntry = null; while ((zipEntry = zis.getNextEntry()) != null) { if (!zipEntry.isDirectory()) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); int c; final byte[] buffer = new byte[512]; while ((c = zis.read(buffer)) != -1) { baos.write(buffer, 0, c); } baos.flush(); resources.put(zipEntry.getName(), baos.toByteArray()); baos.close(); } } zis.close(); in.close(); return resources; } }