Skip to content

Instantly share code, notes, and snippets.

@JorgenRingen
Created December 19, 2018 09:38
Show Gist options
  • Save JorgenRingen/637db2e308a22853d84c1ed768033cac to your computer and use it in GitHub Desktop.
Save JorgenRingen/637db2e308a22853d84c1ed768033cac to your computer and use it in GitHub Desktop.
SpringBoot - Read file from a jar on classpath
private String readContentFromFileInJarOnClasspath() {
try {
return StreamUtils.copyToString(new ClassPathResource("/lol.txt").getInputStream(), Charset.defaultCharset());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment