diff options
Diffstat (limited to 'src/jvm14-library')
-rw-r--r-- | src/jvm14-library/scala/Console.scala | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/jvm14-library/scala/Console.scala b/src/jvm14-library/scala/Console.scala index fe29150caa..0562ec8de1 100644 --- a/src/jvm14-library/scala/Console.scala +++ b/src/jvm14-library/scala/Console.scala @@ -187,11 +187,16 @@ object Console { else MessageFormat.format(text, textParams(args)) ) - /** Read a full line from the terminal. + /** Read a full line from the terminal. Throws EOFException if the end of the + * input stream has been reached. * - * @return the string read from the terminal. + * @return the string read from the terminal. + * @throws java.io.EOFException */ - def readLine(): String = in.readLine() + def readLine(): String = { + val s = in.readLine() + if (s == null) throw new java.io.EOFException("Console has reached end of input") else s + } /** Print a formatted text and read a full line from the terminal * |