How can I read a text file in Android?

前端 未结 7 1485
-上瘾入骨i
-上瘾入骨i 2020-11-22 07:51

I want to read the text from a text file. In the code below, an exception occurs (that means it goes to the catch block). I put the text file in the applicati

7条回答
  •  没有蜡笔的小新
    2020-11-22 08:49

    Shortest form for small text files (in Kotlin):

    val reader = FileReader(path)
    val txt = reader.readText()
    reader.close()
    

提交回复
热议问题