Last active
January 3, 2016 23:59
-
-
Save pete911/8538388 to your computer and use it in GitHub Desktop.
Java - get resources from classpath
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
import org.springframework.core.io.Resource; | |
import org.springframework.core.io.ClassPathResource; | |
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | |
... | |
PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); | |
Resource[] resources = resourceResolver.getResources("conf/**/*.properties"); | |
Resource resource = resources[0]; | |
/* get path */ | |
String path = ((ClassPathResource) resource).getPath(); | |
... | |
--------------------------------------------------------------------------------------------------- | |
import org.springframework.util.ResourceUtils; | |
import java.io.File; | |
... | |
File globalConfig = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX + "some.properties"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment