DataOutputStream.writeUTF runs through its argument String twice using
String.charAt. Instead, it could use String.getChars to get the chars
into a local char and then walk that (twice). This would save two
calls to String.charAt per char, and would avoid the explicit range
checks that String.charAt does. One hopes this change would allow a
good compiler to elide the subscript range checks on the array access,
etc. generating generally better code.
One might want to avoid the extra char if the argument String were
very long, to avoid running out of memory.