First, the output of println () is platform-related. Depending on the machine running the code, the lines are sometimes separated by a newline, sometimes by a carriage return, or by a carriage return/newline pair. Writing to the console does not cause problems, but it is a catastrophe for network clients and servers that follow the exact protocol. Most network protocols, indicating that the carriage return/newline pair should be terminated. Using println () makes it easy to write a program that works with Windows, but does not work on UNIX and Macs. While many servers and clients can be "generous" to handle incorrect line terminators, there are occasional exceptions where a client running on Mac OS 9 uses println () to suspend the server and the client. In some programs, this may be fixed by using only print () and ignoring println ().
Second, all characters printed by PrintStream are converted to bytes using the platform's default character encoding. However, this encoding may not be what the server and client expect. You should use the PrintWriter class in cases where you need to write characters instead of writing bytes.
Third, PrintStream swallowed all the anomalies. is not sufficient for network connectivity.
Citation: Elliotte Rusty Harold Java Network programming