java.io.DataOutputStream.writeUTF() method
 Technote (FAQ)
 
Problem
What is the limitation in the Java API when using the java.io.DataOutputStream.writeUTF( ) method?
 
Solution
When using the java.io.DataOutputStream.writeUTF() method, the java.io.DataOutputStream.writeUTF() method writes a string to the specified DataOutput using UTF-8 encoding. The UTF-8 encoding uses sequences of 1, 2, or 3 bytes per character. Characters from 0 - 127 (the 7-bit ASCII characters) are encoded with one byte, characters from 128 - 2047 require two bytes, and characters from 2048 - 65535 require three bytes. Indeed Strings in UTF format are restricted to an encoded length of 65536.

java.io.DataOutputStream.writeUTF throws a RS4 java.io.UTFDataFormatException when the encoded length of the input string exceeds 65535. Therefore the JDK code is working as per the UTF-8 specification which states that the total encoded number of bytes for the input string should not exceed 65536. Hence we suggest that the input string passed to java.io.DataOutputStream.writeUTF() does not have an encoded length that exceeds 65536.
 
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Java SDK
Operating system(s): HP-UX
Software version: 4.0.1
Software edition:
Reference #: 1053724
IBM Group: Software Group
Modified date: Jun 21, 2002