Introduce Common readln() and readlnOrNull() top-level functions #KT-48456

This commit is contained in:
Abduqodiri Qurbonzoda
2021-09-05 15:31:11 +00:00
committed by Space
parent 14b66872b5
commit 97eb28144f
37 changed files with 271 additions and 6 deletions
+24
View File
@@ -15,5 +15,29 @@ public expect fun println(message: Any?)
/** Prints the given [message] to the standard output stream. */
public expect fun print(message: Any?)
/**
* Reads a line of input from the standard input stream and returns it,
* or throws a [RuntimeException] if EOF has already been reached when [readln] 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].
*/
@SinceKotlin("1.6")
public expect fun readln(): String
/**
* 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].
*/
@SinceKotlin("1.6")
public expect fun readlnOrNull(): String?
internal class ReadAfterEOFException(message: String?) : RuntimeException(message)
internal expect interface Serializable