I want to write to a socket. From reading about network IO, it seems to me that the best way to write to him is to do something like this:
OutputStream outs=null;
BufferedWriter out=null;
out =
new BufferedWriter(
new OutputStreamWriter(new BufferedOutputStream(outs),"UTF-8"));
BufferedWriterwill buffer the input at OutputStreamWriter, which is recommended since it does not allow the author to start the encoder for each character.
It BufferedOutputStreamwill then buffer bytes out Writerto avoid sending one byte at a time, potentially to the network.
It sounds like it’s overkill, but it seems like it helps? Grateful for any help ..
EDIT: from javadoc to OutputStreamWriter:
write() (). , . , . , , write(), .
OutputStreamWriter BufferedWriter, . :
Writer out = new BufferedWriter(new OutputStreamWriter(System.out));