[5132] in java-interest
Re: DataInputStream readLine() method
daemon@ATHENA.MIT.EDU (Pat Niemeyer)
Mon Jan 29 23:46:45 1996
Date: Mon, 29 Jan 1996 21:32:15 -0600 (CST)
From: Pat Niemeyer <pat@icon-stl.net>
To: TWhitehill@banyan.com
cc: java-interest@java.sun.com
In-Reply-To: <vines.J6N6+nEI1lA@ismtp.banyan.com>
On Mon, 29 Jan 1996 TWhitehill@banyan.com wrote:
> The description of the readLine() method reads:
>
> "Reads in a line that has been terminated by a \n, \r, \r\n or EOF."
>
> 1) Is a 'line' a sequence/array of chars, bytes or is it a String?
>
> 2) When I terminate a String with a '\n' and send it from my server via
> DataOutputStream's writeChars() method my applet which
> receives with DataInputStream's readLine() method does nothing. When the
> applet receives the data with readChar() in a loop the String is correctly
> received (with or without the '\n'). Any ideas?
>
> 3) Assuming that I'll get the readLine() method to work correctly, how
> does one terminate it with EOF? I've searched but found nothing.
1) It's a sequence of bytes which are returned as a string with 0 for
the Unicode high bytes of the characters.
2) writeChars() writes 16 bit unicode characters. You probably want to
try using a PrintStream to println() the data as a byte level stream.
(Although I don't know why readLine() wouldn't get some data anyway).
3) Not sure I understand. readLine() returns null on end of stream.
When in doubt, take a look at the source code. It's all right there.
I don't say that to be a jerk, it really is just right there and easy to
read. Simple Java code is better than any documentation will every be ;)
Pat
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com