Summary
DataOutputStream::writeUTF
should explicitly document that a UTFDataFormatException
is thrown if the input string is too long.
Problem
DataOutputStream::writeUTF
will throw a UTFDataFormatException
exception if the encoded UTF-8 character string is longer than 65535.
Solution
Document that DataOutputStream::writeUTF
will throw a UTFDataFormatException
exception if the encoded UTF-8 character string is longer than 65535.
Specification
java.io.DataOutputStream
:
@@ -317,7 +317,10 @@
* thrice the length of <code>str</code>.
*
* @param str a string to be written.
- * @exception IOException if an I/O error occurs.
+ * @throws UTFDataFormatException if the modified UTF-8 encoding of
+ * {@code str} would exceed 65535 bytes in length
+ * @throws IOException if some other I/O error occurs.
+ * @see #writeChars(String)
*/
public final void writeUTF(String str) throws IOException {}
- csr of
-
JDK-8219196 DataOutputStream.writeUTF may throw unexpected exceptions
-
- Resolved
-