The suggested fix is to assemble the result of writeUTF into a local byte
and then do a single write(byte, ...). That copies the bytes an extra
time (with System.arraycopy in ByteArrayOutputStream), but it avoids a lot
of synchronized calls.
The parallel fix in DataInputStream.readUTF is, after you figure out how long
the incoming UTF is, to do a readFully(byte,...) to a local byte and
then extract bytes from that array rather than calling readUnsignedByte()
for each byte.