readlnOrNull

Platform and version requirements: JVM (1.6), JS (1.6), Native (1.6)
fun readlnOrNull(): String?
For JVM

Reads a line of input from the standard input stream and returns it, or return null if EOF has already been reached when readlnOrNull is called.

LF or CRLF is treated as the line terminator. Line terminator is not included in the returned string.

The input is decoded using the system default Charset. A CharacterCodingException is thrown if input is malformed.

For Common

Reads a line of input from the standard input stream and returns it, or return null if EOF has already been reached when readlnOrNull is called.

LF or CRLF is treated as the line terminator. Line terminator is not included in the returned string.

Currently this function is not supported in Kotlin/JS and throws UnsupportedOperationException.

For Native

Reads a line of input from the standard input stream and returns it, or return null if EOF has already been reached when readlnOrNull is called.

LF or CRLF is treated as the line terminator. Line terminator is not included in the returned string.

The input is interpreted as UTF-8. Invalid bytes are replaced by the replacement character '\uFFFD'.

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/readln-or-null.html