Created
January 16, 2018 07:40
-
-
Save vamsitallapudi/3c14d991333577abffbe48c44f7746c4 to your computer and use it in GitHub Desktop.
Read a file in Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
val inputStream:InputStream = assets.open("news_data_file.json") | |
val inputStreamReader = InputStreamReader(inputStream) | |
val sb = StringBuilder() | |
var line: String? | |
val br = BufferedReader(inputStreamReader) | |
line = br.readLine() | |
while (br.readLine() != null) { | |
sb.append(line) | |
line = br.readLine() | |
} | |
br.close() | |
Log.d(TAG,sb.toString()) | |
} catch (e:Exception){ | |
Log.d(TAG, e.toString()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment