Fix DataOutputStream#writeUTF

This developer did not read the specs closely enough and missed that
the length of the byte array needs to be written out first, so that
DataInputStream#readUTF has a chance of reading the string back.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2013-11-01 17:49:48 -05:00
parent 759a08bb54
commit 209f2a3aff

View File

@ -92,6 +92,8 @@ public class DataOutputStream extends OutputStream implements DataOutput {
}
public void writeUTF(String s) throws IOException {
out.write(s.getBytes("UTF-8"));
byte[] bytes = s.getBytes("UTF-8");
writeShort((short)bytes.length);
out.write(bytes);
}
}