How To Read Entire Text / JSON File in 1 Line of Kotlin Code
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.
Some other alternatives to read file
Read all lines as ArrayList<String>
val lines = Files.readAllLines( encoding) println(lines)
Reading as bytes
val encoded = Files.readAllBytes(Paths.get("my-test.json")) val asText = String(encoded, encoding)