Java Folder Read getFilesCount(File archiveFile)

Here you can find the source of getFilesCount(File archiveFile)

Description

get Files Count

License

Open Source License

Parameter

Parameter Description
archiveFile the zip file

Exception

Parameter Description
IOException an exception

Return

the number of files contained in this zip file

Declaration

public static int getFilesCount(File archiveFile) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 ARM Ltd. and others
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// www.  j  av a  2 s.c om
 * ARM Ltd and ARM Germany GmbH - Initial API and implementation
 *******************************************************************************/

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
    /**
     * @param archiveFile the zip file
     * @return the number of files contained in this zip file
     * @throws IOException
     */
    public static int getFilesCount(File archiveFile) throws IOException {
        ZipInputStream zipInput;
        zipInput = new ZipInputStream(new FileInputStream(archiveFile));
        ZipEntry zipEntry = zipInput.getNextEntry();
        int count = 0;
        while (zipEntry != null) {
            if (!zipEntry.isDirectory()) {
                count++;
            }
            zipEntry = zipInput.getNextEntry();
        }
        zipInput.closeEntry();
        zipInput.close();

        return count;
    }
}

Related

  1. getFilesByRegxFileName(String dir, final String regxName)
  2. getFilesByType(String fileType, String path)
  3. getFilesByType(String path, final String type)
  4. getFilesCannotAccess(File... files)
  5. getFilesComposingPath(File aFile)
  6. getFileset(File projectFolder)
  7. getFilesFolder(String path)
  8. getFilesFor(List patientSets, File inputDirectory)
  9. getFilesForDirectory(File dir)