Created
September 1, 2017 15:13
-
-
Save tmichel/975aea1051d0b6bffea9be1a783569c7 to your computer and use it in GitHub Desktop.
List files on the classpath with guava Resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<String> getFiles() { | |
String fixturesRoot = Resources.getResource("fixtures").getPath(); | |
final Path fixturesRootPath = Paths.get(fixturesRoot); | |
try { | |
return Files.walk(fixturesRootPath) | |
.filter(Files::isRegularFile) | |
.map(path -> fixturesRootPath.relativize(path).toString()) | |
.collect(Collectors.toList()); | |
} catch (IOException e) { | |
throw new IllegalArgumentException(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment