Browse Source

[java] Catch end of file on stdin

Jonas Malaco Filho 12 years ago
parent
commit
94b2a1c1f4
1 changed files with 5 additions and 5 deletions
  1. 5 5
      std/java/io/NativeInput.hx

+ 5 - 5
std/java/io/NativeInput.hx

@@ -37,17 +37,17 @@ import java.io.EOFException;
 
 	override public function readByte():Int
 	{
+		var ret = 0;
 		try
 		{
-			return stream.read();
-		}
-		catch (e:EOFException) {
-			throw new Eof();
+			ret = stream.read();
 		}
-
 		catch (e:IOException) {
 			throw haxe.io.Error.Custom(e);
 		}
+		if ( ret == -1 )
+			throw new Eof();
+		return ret;
 	}
 
 	override public function readBytes(s:Bytes, pos:Int, len:Int):Int