Skip to content

Instantly share code, notes, and snippets.

@yHori12
Last active April 25, 2019 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yHori12/b8918a229e2b024d5b7fa0dba65ad009 to your computer and use it in GitHub Desktop.
Save yHori12/b8918a229e2b024d5b7fa0dba65ad009 to your computer and use it in GitHub Desktop.
import java.io.File
val inputStream = File("Jugemu.txt").inputStream()
val readAllLinesWithInputStream: String
get() {
return inputStream.bufferedReader().use {
it.readText()
}
}
val bufferedReader = File("Jugemu.txt").bufferedReader()
val readEachLinesWithBufferedReader: List<String>
get() {
val lineList = mutableListOf<String>()
bufferedReader.useLines { lines ->
lines.forEach {
lineList.add(it)
}
}
return lineList
}
fun main() {
print(readAllLinesWithInputStream)
readEachLinesWithBufferedReader.forEach {
println(it)
}
}
try {
val inputStream:InputStream = assets.open("news_data_file.json")
val inputString = inputStream.bufferedReader().use{it.readText()}
Log.d(TAG,inputString)
} 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