Created
April 29, 2017 16:17
-
-
Save StasKolodyuk/0ff9dd908b2f39a9c31e361594f000f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment