Here you can find the source of listFiles(Path directory, String glob)
Glob matcher is explained java.nio.file.FileSystem#getPathMatcher(String) getPatchMatcher .License
Open Source LicenseDeclaration
public static List<Path> listFiles(Path directory, String glob) throws IOExceptionMethod Source Code
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.file.*; import java.util.ArrayList; import java.util.List; public class Main { /**/*from ww w . j a va 2s. c o m*/ * <pre> * Glob matcher is explained {@link java.nio.file.FileSystem#getPathMatcher(String) getPatchMatcher}. * * Examples: * "*.{c,h,cpp,hpp,java}" * "*.java" * </pre> */ public static List<Path> listFiles(Path directory, String glob) throws IOException { List<Path> result = new ArrayList<>(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory, glob)) { stream.forEach(result::add); } catch (DirectoryIteratorException ex) { throw ex.getCause(); } return result; } }Related