From 808ce120ae43633728dd0346abe2c09707b22f27 Mon Sep 17 00:00:00 2001 From: Urban Widmark Date: Mon, 12 Apr 1999 20:27:56 +0200 Subject: [PATCH] DataInputStream.java (readLine): Corrected handling of empty lines, from null to "". 1999-04-12 Urban Widmark * java/io/DataInputStream.java (readLine): Corrected handling of empty lines, from null to "". From-SVN: r26381 --- libjava/ChangeLog | 5 +++++ libjava/java/io/DataInputStream.java | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3beb48cbc62..9b8323a7c0d 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +1999-04-12 Urban Widmark + + * java/io/DataInputStream.java (readLine): Corrected handling of + empty lines, from null to "". + 1999-04-12 Tom Tromey * Makefile.in: Rebuilt. diff --git a/libjava/java/io/DataInputStream.java b/libjava/java/io/DataInputStream.java index 7c90008c6e0..d03f8f4da3e 100644 --- a/libjava/java/io/DataInputStream.java +++ b/libjava/java/io/DataInputStream.java @@ -105,8 +105,11 @@ public class DataInputStream extends FilterInputStream implements DataInput while (true) { - char ch = (char) read(); - if (ch < 0 || (ch &= 0xFF) == '\n') + int c = read(); + if (c < 0) // got an EOF + return strb.length() > 0 ? strb.toString() : null; + char ch = (char) c; + if ((ch &= 0xFF) == '\n') break; if (ch == '\r') { @@ -148,7 +151,7 @@ public class DataInputStream extends FilterInputStream implements DataInput strb.append(ch); } - return strb.length() > 0 ? strb.toString() : null; + return strb.length() > 0 ? strb.toString() : ""; } public final long readLong() throws IOException