22.2
java.io.DataOutput
THE PACKAGE JAVA.IO
of the
writeByte
method ( 22.2.5). The high order eight bits of each character in
the string are ignored.
22.2.13
public void writeChars(String s)
throws IOException, NullPointerException
The general contract for
writeChars
is that every character in the string
s
is writ
ten, in order, to the output stream, two bytes per character.
If
s
is
null
, a
NullPointerException
is thrown.
If
s.length
is zero, then no characters are written. Otherwise, the character
s[0]
is written first, then
s[1]
, and so on; the last character written is
s[s.length 1]
. For each character, two bytes are actually written, high order
byte first, in exactly the manner of the
writeChar
method ( 22.2.7).
22.2.14
public void writeUTF(String s)
throws IOException, NullPointerException
The general contract for
writeUTF
is that two bytes of length information are
written to the output stream, followed by the Java modified UTF representation of
every character in the string
s
.
If
s
is
null
, a
NullPointerException
is thrown.
Each character in the string
s
is converted to a group of one, two, or three
bytes, depending on the value of the character.
If a character
c
is in the range
\u0001
through
\u007f
, it is represented
by one byte:
(byte)c
If a character
c
is
\u0000
or is in the range
\u0080
through
\u07ff
,
then it is represented by two bytes, to be written in the order shown:
(byte)(0xc0 | (0x1f & (c >> 6)))
(byte)(0x80 | (0x3f & c))
If a character
c
is in the range
\u0800
through
\uffff
, then it is repre
sented by three bytes, to be written in the order shown:
(byte)(0xc0 | (0x0f & (c >> 12)))
(byte)(0x80 | (0x3f & (c >>
6)))
(byte)(0x80 | (0x3f & c))
First, the total number of bytes needed to represent all the characters of
s
is
calculated. If this number is larger than
65535
, then a
UTFDataFormatError
is
thrown. Otherwise, this length is written to the output stream in exactly the
678
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved