FileUtil { public static String[] getFilesFromDirectory( String baseDir, String[] includes, String[] excludes) throws IOException { final List<String> fileNames = new ArrayList<>(); final Path baseDirPath = Paths.get(baseDir); FileSystem fileSystem = baseDirPath.getFileSystem(); final List<PathMatcher> includePathMatchers = _getPathMatchers( fileSystem, baseDirPath, includes); final List<PathMatcher> excludePathMatchers = _getPathMatchers( fileSystem, baseDirPath, excludes); Files.walkFileTree( baseDirPath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile( Path path, BasicFileAttributes basicFileAttributes) { path = path.toAbsolutePath(); for (PathMatcher pathMatcher : excludePathMatchers) { if (pathMatcher.matches(path)) { return FileVisitResult.CONTINUE; } } for (PathMatcher pathMatcher : includePathMatchers) { if (pathMatcher.matches(path)) { String fileName = String.valueOf( baseDirPath.relativize(path)); fileNames.add(fileName); break; } } return FileVisitResult.CONTINUE; } }); return fileNames.toArray(new String[0]); }  static void deltree(Path dirPath); static String[] getFilesFromDirectory(
			String baseDir, String[] includes, String[] excludes); static File getJarFile(); static long getLastModifiedTime(Path path); static boolean isAbsolute(String fileName); static void write(File file, String content);  }
@Test public void testGetFilesFromDirectory() throws IOException { File baseDir = temporaryFolder.newFolder("tmp"); FileTestUtil.createFiles( baseDir, ".sass-cache/_general.scss", ".sass-cache/general.scss", ".sass-cache_/_general.scss", ".sass-cache_/general.scss", ".sass-cache_1/_general.scss", ".sass-cache_1/general.scss", "/_diffs/foo.scss", "/_diffs/foo/_bar.scss", "/foo/bar/.sass-cache/_general.scss", "/foo/bar/.sass-cache/general.scss", "/foo/bar/.sass-cache_/_general.scss", "/foo/bar/.sass-cache_/general.scss", "/foo/bar/.sass-cache_1/_general.scss", "/foo/bar/.sass-cache_1/general.scss", "/foo/bar/_sass-cache/_general.scss", "/foo/bar/_sass-cache/general.scss", "/foo/tmp/_foo.scss", "_general.scss", "_sass-cache/_general.scss", "_sass-cache/general.scss", "_toolbar.scss", "foo.scss", "tmp/_foo.scss"); String[] fileNames = FileUtil.getFilesFromDirectory( baseDir.toString(), new String[] {"**/_*.scss"}, _EXCLUDES); if (File.separatorChar != '/') { for (int i = 0; i < fileNames.length; i++) { String fileName = fileNames[i]; fileNames[i] = fileName.replace(File.separatorChar, '/'); } } Arrays.sort(fileNames); Assert.assertArrayEquals( new String[] { "_general.scss", "_sass-cache/_general.scss", "_toolbar.scss", "foo/bar/_sass-cache/_general.scss" }, fileNames); }