[5154] in java-interest

home help back first fref pref prev next nref lref last post

Re: DataInputStream readLine() method

daemon@ATHENA.MIT.EDU (Walter Szewelanczyk)
Tue Jan 30 11:06:54 1996

From: "Walter Szewelanczyk" <Walter@stumpy.adco.com>
To: TWhitehill@banyan.com, java-interest@java.sun.com
Date: Tue, 30 Jan 1996 09:30:15 +0000




TWhitehill@banyan.com at  Mon, 29 Jan 96 17:03:34 EST 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.


I think it is looking for bytes so you could change you writeChar to 
writeByte and that should work but if you are sending only String 
data then I think that using a PrintStream is much easier.  for 
instance

.... Previously create MySocket.....

PrintStream psOut = new PrintStream(MySocket.getOutputStream());
psOut.println("Send Me");


That will send a string that can be read with readLine on the other 
end.

As far as the EOF is concerned I would assume closing the connection 
should result in an EOF but I am not sure.

Hope this helps,

Walt



 

********************************************************************************************
Walter Szewelanczyk					Technical Director 
Walter@adco.com						NET VENTURE, Inc.


	"One must stay in a very RIGID state of FLEXABILITY"

********************************************************************************************
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post