Here you can find the source of getZipEntryStream(File zipFile, String entryName)
Parameter | Description |
---|---|
zipFile | a parameter |
entryName | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static InputStream getZipEntryStream(File zipFile, String entryName) throws IOException
//package com.java2s; /**/* w w w . j a v a 2 s .co m*/ * This program and the accompanying materials * are made available under the terms of the License * which accompanies this distribution in the file LICENSE.txt */ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { /** * @param zipFile * @param entryName * @return A Zip Entry Stream * @throws IOException */ public static InputStream getZipEntryStream(File zipFile, String entryName) throws IOException { ZipEntry zipEntry; ZipInputStream zIn; BufferedInputStream in = new BufferedInputStream(new FileInputStream(zipFile)); zIn = new ZipInputStream(in); // Get zip entry while ((zipEntry = zIn.getNextEntry()) != null) { String zipEntryName = zipEntry.getName(); if (zipEntryName.equalsIgnoreCase(entryName)) { break; } zIn.closeEntry(); } // If we didn't get it return null if (zipEntry == null) { try { zIn.close(); } catch (IOException ex) { } return null; } return zIn; } }