Here you can find the source of getZipFileList(InputStream is)
Parameter | Description |
---|---|
is | the inputstream data |
public static List<String> getZipFileList(InputStream is)
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { /**//from w ww .j a v a 2 s. c om * get the files in the zip file. * * @param fileName * zip file name. is a full path for the file. * @return return a List contain the files in the zip file. if the file is * not exists return null. */ public static List<String> getZipFileList(String fileName) { try { return getZipFileList(new FileInputStream(new File(fileName))); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } /** * get the file list in the inputstream data * * @param is * the inputstream data * @return the file list contain in the inputstream. if the is is null * return null */ public static List<String> getZipFileList(InputStream is) { List<String> ret = new ArrayList<String>(); try { ZipInputStream in = new ZipInputStream(is); ZipEntry entry = null; while ((entry = in.getNextEntry()) != null) { ret.add(entry.getName()); } return ret; } catch (Exception e) { e.printStackTrace(); } return null; } }