There is a strange restriction in java.io.DataOutputStream.writeUTF(String str)
method, which limits the size of an UTF-8 encoded string to 65535
bytes:
if (utflen > 65535)
throw new UTFDataFormatException(
"encoded string too long: " + utflen + " bytes");
It is strange, because:
- there is no any information about this restriction in JavaDoc of this method
- this restriction can be easily solved by copying and modifying an internal
static int writeUTF(String str, DataOutput out)
method of this class - there is no such restriction in the opposite method
java.io.DataInputStream.readUTF()
.
According to the said above I can not understand the purpose of a such restriction in the writeUTF
method. What have I missed or misunderstood?