📜  读取文件 kotlin 代码示例

📅  最后修改于: 2022-03-11 14:53:33.807000             🧑  作者: Mango

代码示例2
//internal storage
var fileInputStream: FileInputStream? = null  
fileInputStream = openFileInput(filename)  
var inputStreamReader: InputStreamReader = InputStreamReader(fileInputStream)  
val bufferedReader: BufferedReader = BufferedReader(inputStreamReader)  
val stringBuilder: StringBuilder = StringBuilder()  
var text: String? = null  
while ({ text = bufferedReader.readLine(); text }() != null) {  
    stringBuilder.append(text)  
}  
//Displaying data on EditText  
fileData.setText(stringBuilder.toString()).toString()