summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-05-01 12:45:55 +0000
committerGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-05-01 12:45:55 +0000
commite5a1fb508d855a0b6891b40095f75f92703987a1 (patch)
tree18307bb432722617255251ed1cb17ff62a276054
parent3e1e2078f7785292dd99566fcfc5d7d8264b7013 (diff)
downloadscala-e5a1fb508d855a0b6891b40095f75f92703987a1.tar.gz
scala-e5a1fb508d855a0b6891b40095f75f92703987a1.tar.bz2
scala-e5a1fb508d855a0b6891b40095f75f92703987a1.zip
Console.readLine() now throws EOFException inst...
Console.readLine() now throws EOFException instead of returning null.
-rw-r--r--src/jvm14-library/scala/Console.scala11
-rw-r--r--src/library/scala/Console.scala10
2 files changed, 15 insertions, 6 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
*
diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala
index 519fab403d..204d7d7c35 100644
--- a/src/library/scala/Console.scala
+++ b/src/library/scala/Console.scala
@@ -186,12 +186,16 @@ object Console {
out.printf(text, args.asInstanceOf[scala.runtime.BoxedObjectArray].
unbox(args.getClass).asInstanceOf[Array[Object]])
- /** Read a full line from the terminal. Returns null if the end of the
+ /** 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.
* Returns null if the end of the input stream has been reached.