Java examples for File Path IO:Zip File
list Zip Entries
/*/* w ww . j a v a2 s .c om*/ * CODENVY CONFIDENTIAL * __________________ * * [2012] - [2013] Codenvy, S.A. * All Rights Reserved. * * NOTICE: All information contained herein is, and remains * the property of Codenvy S.A. and its suppliers, * if any. The intellectual and technical concepts contained * herein are proprietary to Codenvy S.A. * and its suppliers and may be covered by U.S. and Foreign Patents, * patents in process, and are protected by trade secret or copyright law. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Codenvy S.A.. */ //package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { public static Collection<String> listEntries(File zip) throws IOException { return listEntries(new FileInputStream(zip)); } public static Collection<String> listEntries(InputStream in) throws IOException { List<String> list = new ArrayList<String>(); ZipInputStream zipIn = null; try { zipIn = new ZipInputStream(in); ZipEntry zipEntry; while ((zipEntry = zipIn.getNextEntry()) != null) { if (!zipEntry.isDirectory()) { list.add(zipEntry.getName()); } zipIn.closeEntry(); } } finally { if (zipIn != null) { zipIn.close(); } in.close(); } return list; } }