Skip to content

Instantly share code, notes, and snippets.

@tmichel
Created September 1, 2017 15:13
Show Gist options
  • Save tmichel/975aea1051d0b6bffea9be1a783569c7 to your computer and use it in GitHub Desktop.
Save tmichel/975aea1051d0b6bffea9be1a783569c7 to your computer and use it in GitHub Desktop.
List files on the classpath with guava Resources
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