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 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)); | |
} | |
} |