[patch] "\r\n" handling in DataInputStream.readLine()
Bryce McKinlay
bryce@albatross.co.nz
Wed Jun 2 04:52:00 GMT 1999
Here is an updated version of my DataInputStream.readLine() patch - this adds fixes
for a bug in the existing code, where '\r' is followed by an EOF.
Bryce McKinlay wrote:
> I agree that its not worth sacrificing extra complexity in other methods to 100%
> correctly implement a broken (and deprecated) spec.
>> My patch (I believe) correctly implements readLine() assuming it is not called in
> combination with the other read methods. I think it is very unlikely that code
> that is using the readLine() method is going to be calling combinations of
> readLine() and the other read() methods on the same stream.
>> In any case, the behaviour with the patch is better than how it is implemented
> now.
>> > Note if we leave the code as is, I think there is still a bug: The tests
> > for (read() & 0xFF) != '\n' will do the wrong thing on EOF.
More information about the Java
mailing list