Java tutorial
/* * ENTRADA, a big data platform for network data analytics * * Copyright (C) 2016 SIDN [https://www.sidn.nl] * * This file is part of ENTRADA. * * ENTRADA 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 3 of the License, or * (at your option) any later version. * * ENTRADA 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 ENTRADA. If not, see [<http://www.gnu.org/licenses/]. * */ package nl.sidn.pcap.util; import java.io.File; import java.util.Iterator; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FileUtil { private static final Logger LOGGER = LoggerFactory.getLogger(FileUtil.class); public static int countFiles(String inputDir) { LOGGER.info("Scan for pcap files in: " + inputDir); File f = FileUtils.getFile(inputDir); Iterator<File> files = FileUtils.iterateFiles(f, new String[] { "pcap.gz" }, false); int filecount = 0; while (files.hasNext()) { files.next(); filecount++; } return filecount; } }