[2343] in java-interest
Re: Socket Communication
daemon@ATHENA.MIT.EDU (Jonathan Payne)
Fri Sep 29 16:35:41 1995
Date: Fri, 29 Sep 1995 10:55:07 -0700
From: jpayne@starwave.com (Jonathan Payne)
To: mentor@io.org
Cc: dhamner@email.unc.edu, java-interest@java.sun.com
In-Reply-To: <v01510103ac91d2c81b1b@[204.92.53.11]> (mentor@io.org)
> OOPS! No, it seems to have fallen off the edge of the world.
> DataInputStream also provides a readLine, but it accesses the data a byte
> at a time through a method invocation. Thus, if you construct the
> DataInputStream with an unbuffered input stream, your readLine will
> effectively be unbuffered. TextInputStream buffered things for you. Another
> difference between the two would seem to be the treatment of '\r' and '\n'
> - DataInputStream will not treat '\r' as a terminator.
TextInputStream was a mistake.
If you are worried about reading the bytes one at a time, then you
stick a BufferedInputStream in the loop:
DataInputStream dis = new DataInputStream(new BufferedInputStream(socketInput));
while ((line = dis.readLine()) != null)
...
The version of readLine() in the beta DataInputStream can handle "\r",
"\n", and "\r\n" as line terminators.
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com