Java File List Load getFileList(String zipFilePath)

Here you can find the source of getFileList(String zipFilePath)

Description

Obtains an ArrayList of the contents of the zip file (files and directories).

License

Open Source License

Parameter

Parameter Description
zipFilePath the name of the zip file

Exception

Parameter Description
IOException an exception

Return

a list of Strings, representing the contents of the zip file

Declaration

public static ArrayList<String> getFileList(String zipFilePath)
        throws IOException 

Method Source Code

//package com.java2s;
/************************************************************
 * Copyright (c) 2015, Lawrence Livermore National Security, LLC.
 * Produced at the Lawrence Livermore National Laboratory.
 * Written by Timothy Meier, meier3@llnl.gov, All rights reserved.
 * LLNL-CODE-673346/*from  ww w. j ava 2s.c o m*/
 *
 * This file is part of the OpenSM Monitoring Service (OMS) package.
 * 
 * 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) version 2.1 dated February 1999.
 * 
 * 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 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, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * OUR NOTICE AND TERMS AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE
 *
 * Our Preamble Notice
 *
 * A. This notice is required to be provided under our contract with the U.S.
 * Department of Energy (DOE). This work was produced at the Lawrence Livermore
 * National Laboratory under Contract No.  DE-AC52-07NA27344 with the DOE.
 *
 * B. Neither the United States Government nor Lawrence Livermore National
 * Security, LLC nor any of their employees, makes any warranty, express or
 * implied, or assumes any liability or responsibility for the accuracy,
 * completeness, or usefulness of any information, apparatus, product, or
 * process disclosed, or represents that its use would not infringe privately-
 * owned rights.
 *
 * C. Also, reference herein to any specific commercial products, process, or
 * services by trade name, trademark, manufacturer or otherwise does not
 * necessarily constitute or imply its endorsement, recommendation, or favoring
 * by the United States Government or Lawrence Livermore National Security,
 * LLC. The views and opinions of authors expressed herein do not necessarily
 * state or reflect those of the United States Government or Lawrence Livermore
 * National Security, LLC, and shall not be used for advertising or product
 * endorsement purposes.
 *
 *        file: ZipUtil.java
 *
 *  Created on: Jan 9, 2014
 *      Author: meier3
 ********************************************************************/

import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;

import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {
    /**
     * Obtains an ArrayList of the contents of the zip file (files and directories).
     *
     * @see     ZipFile
     *
     * @param zipFilePath   the name of the zip file
     * @return              a list of Strings, representing the contents of the zip file
     * @throws IOException
     ***********************************************************/
    public static ArrayList<String> getFileList(String zipFilePath)
            throws IOException {
        java.util.ArrayList<String> sArray = new java.util.ArrayList<String>();
        ZipFile zFile = new ZipFile(zipFilePath);
        Enumeration<? extends ZipEntry> entries = zFile.entries();

        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            String filePath = entry.getName();
            sArray.add(filePath);
        }
        return sArray;
    }
}

Related

  1. getFileList(String path)
  2. getFileList(String path, String filterName)
  3. getFileList(String path, String regex)
  4. getFileList(String path, String searchString)
  5. getFileList(String s)
  6. getFileListByDFS(File file)
  7. getFileListByExtension(final String location, final String extension)
  8. getFileListByRegex(String dir, final String regex)
  9. getFileListDeep(File path)