Here is my code that I have which is pretty simple and to the point:
public void sendMessage(String message)
{
writer.println(message);
writer.flush();
}
I don’t really like to use PrintWriter cause it tends to swallow IOExceptions, this is really the only thing I’m using it for besides sending byte arrays. What can I use instead that won’t consume IOExceptions and will still give me the functionality of PrintWriter?
I’d recommend using a plain
Writeror aBufferedWriteror
But obviously it depends on what functionality of
PrintWriteryou want to retain.