I wanted to read an entire json file which contains my test request. I found this very quick and super simple 1 line to read an entire file as string.

Quickest Solution


Some other alternatives to read file

Read all lines as ArrayList<String>

val lines = Files.readAllLines( encoding)

Reading as bytes

val encoded = Files.readAllBytes(Paths.get("my-test.json"))
val asText = String(encoded, encoding)