Skip to content

Instantly share code, notes, and snippets.

View StasKolodyuk's full-sized avatar

Stas StasKolodyuk

  • TimbrelMasters
  • Belarus
View GitHub Profile
public static void copyDirectoryFromResources(String source, final String target) throws IOException {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources(source + "/**");
for (Resource resource : resources) {
if (resource.isReadable() && resource.contentLength() > 0) {
String relativePath = StringUtils.substringAfter(resource.getURL().toExternalForm(), source);
FileUtils.copyURLToFile(resource.getURL(), new File(target, relativePath));
}
}