List of usage examples for java.nio.file DirectoryStream forEach
default void forEach(Consumer<? super T> action)
From source file:org.esa.snap.engine_utilities.util.ZipUtils.java
public static void zipFolder(final Path directory, final File outputZipFile) throws IOException { try (ZipOutputStream zipStream = new ZipOutputStream(new FileOutputStream(outputZipFile))) { // traverse every file in the selected directory and add them // to the zip file by calling addToZipFile(..) DirectoryStream<Path> dirStream = Files.newDirectoryStream(directory); dirStream.forEach(path -> addToZipFile(path.toFile(), zipStream)); } catch (IOException e) { throw e;//from w ww .j a v a2 s . co m } }