My code is simple.
When I execute Main function, I can enter number for only once.
If I enter second number, IOException: Stream closed
occurs.
Can you explain why?
import java.io.*
fun main() {
for (i in 0 until 5)
val number = readLine().toInt()
}
fun readLine(): String {
BufferedReader(InputStreamReader(System.`in`)).use { reader ->
return reader.readLine()
}
}