-
-
Save jmewes/09c188a94fc5bba10c8c48b8b1409f08 to your computer and use it in GitHub Desktop.
How to read in resources as File object?
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
private static File getResourceAsFile(String resourcePath) { | |
URL resourceUrl = Thread.currentThread().getContextClassLoader().getResource(resourcePath); | |
try { | |
return new File(resourceUrl.toURI()); | |
} catch (URISyntaxException e) { | |
throw new RuntimeException(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment