Skip to content

Instantly share code, notes, and snippets.

@jknair0
Created May 10, 2019 04:41
Show Gist options
  • Select an option

  • Save jknair0/d4a261eb5a31c0892d0cdf2e59535146 to your computer and use it in GitHub Desktop.

Select an option

Save jknair0/d4a261eb5a31c0892d0cdf2e59535146 to your computer and use it in GitHub Desktop.
Read test resource file
fun readContent(fileNameWithExt: String): String? {
return try {
val classLoader = javaClass.classLoader
val resource = classLoader.getResource(fileNameWithExt)
val file = File(resource.file)
file.readText()
} catch (e: Exception) {
null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment