Problem with writing a Line to a Data Stream

I am writing a server <--> applet type of game.

I want to send player actions as strings that I can parse for neccessary

data.

First I used DataInputStream and DataOutputStream, but I found that

the readLine method of DataInputStream is depricated and sun

recommends the use of BufferedReader instead.

This works fine, but I can not find a corresponding writeLine in either

BufferedWriter or DataOutputStream. The best I have come up with is

DataOutputStream.writeChars(String s) but the string I read at the

server arrives with a white space between each character.

I.e. sending String s = "test" from the client generates "t e s t " at the

server.

I guess I could loop through the string and strip any white space but

there has to be a more elegant solution.

Grateful for any help,

Logros

[906 byte] By [Logrosa] at [2007-10-2 13:50:03]
# 1

This should work

BufferedWriter writer = //blah

public void writeLine(String line){

try{

writer.write(line, 0, line.length()) ;

writer.newLine();

writer.flush();

}catch(IOException IOEx){

//do something

}

}

Michael

pascoe213a at 2007-7-13 11:50:10 > top of Java-index,Other Topics,Java Game Development...
# 2
DataOutputStream myDos = ....;PrintStream printer = new PrintStream(myDos);printer.println("Just like System.out.println, wow!");
DaanSa at 2007-7-13 11:50:10 > top of Java-index,Other Topics,Java Game Development...
# 3
Thank you both for your help!I went with DaanS' solution (since it was shorter).Again, thanks.Logros
Logrosa at 2007-7-13 11:50:10 > top of Java-index,Other Topics,Java Game Development...