ResourceHelper { public static Stream<String> getResourcesByExtension(String extension) { return Arrays.stream(getClassPathElements()) .flatMap(elem -> internalGetResources(elem, Pattern.compile(".*\\." + extension + "$"))); } private  ResourceHelper(); static Stream<String> getResourcesByExtension(String extension); static Stream<String> getResourcesFromDirectory(File directory, Pattern pattern);  }
@Test public void getResourcesByExtensionTest() { Stream<String> txtResources = getResourcesByExtension("txt"); List<String> resources = txtResources.collect(Collectors.toList()); assertEquals(1, resources.size()); assertTrue(resources.stream().anyMatch(elem -> elem.endsWith("testFile.txt"))); }