Skip to content

Instantly share code, notes, and snippets.

@matteo-grella
Created May 17, 2019 10:02
Show Gist options
  • Save matteo-grella/0e212dce08f54bfa86fcedb3843cbb48 to your computer and use it in GitHub Desktop.
Save matteo-grella/0e212dce08f54bfa86fcedb3843cbb48 to your computer and use it in GitHub Desktop.
/**
* @param resource the path to the resource to load
*
* @return the content of the resource
*/
fun loadResource(resource: String): String =
try {
object {}.javaClass.getResource(resource).readText(Charsets.UTF_8)
} catch (all: Exception) {
throw RuntimeException("Failed to load resource=$resource!", all)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment