Skip to content

Instantly share code, notes, and snippets.

@canergulgec
Created January 24, 2021 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canergulgec/64abf46c431ae600b255617477dac642 to your computer and use it in GitHub Desktop.
Save canergulgec/64abf46c431ae600b255617477dac642 to your computer and use it in GitHub Desktop.
object FileReader {
fun readTestResourceFile(fileName: String): String {
try {
val inputStream = (InstrumentationRegistry.getInstrumentation().targetContext
.applicationContext as MovieTestApp).assets.open(fileName)
val builder = StringBuilder()
val reader = InputStreamReader(inputStream, "UTF-8")
reader.readLines().forEach {
builder.append(it)
}
return builder.toString()
} catch (e: IOException) {
throw e
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment