Last active
April 25, 2019 07:00
-
-
Save yHori12/b8918a229e2b024d5b7fa0dba65ad009 to your computer and use it in GitHub Desktop.
This file contains 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
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) | |
} | |
} |
This file contains 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 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