22.1
java.io.DataInput
THE PACKAGE JAVA.IO
22.1.14
public String readLine() throws IOException
The general contract of
readLine
 is that it reads successive bytes, converting
each byte separately into a character, until it encounters a line terminator or end of
file; the characters read are then returned as a
String
. Note that because this
method processes bytes, it does not support input of the full Unicode character set.
If end of file is encountered before even one byte can be read, then
null
 is
returned. Otherwise, each byte that is read is converted to type
char
 by zero 
extension. If the character
 \n 
 is encountered, it is discarded and reading ceases.
If the character
 \r 
 is encountered, it is discarded and, if the following byte
converts to the character
 \n 
, then that is discarded also; reading then ceases. If
end of file is encountered before either of the characters
 \n 
 and
 \r 
 is encoun 
tered, reading ceases. Once reading has ceased, a
String
 is returned that contains
all the characters read and not discarded, taken in order. Note that every character
in this string will have a value less than
\u0100
, that is,
(char)256
.
22.1.15
public String readUTF() throws IOException
The general contract of
readUTF
 is that it reads a representation of a Unicode
character string encoded in Java modified UTF 8 format; this string of characters
is then returned as a
String
.
First, two bytes are read and used to construct an unsigned 16 bit integer in
exactly the manner of the
readUnsignedShort
 method ( 22.1.8). This integer
value is called the
UTF length
 and specifies the number of additional bytes to be
read. These bytes are then converted to characters by considering them in groups.
The length of each group is computed from the value of the first byte of the group.
The byte following a group, if any, is the first byte of the next group.
If the first byte of a group matches the bit pattern
0xxxxxxx
 (where
x
 means
 may be
0
 or
1
 ), then the group consists of just that byte. The byte is zero 
extended to form a character.
If the first byte of a group matches the bit pattern
110xxxxx
, then the group
consists of that byte
a
 and a second byte
b
. If there is no byte
b
 (because byte
a
was the last of the bytes to be read), or if byte
b
 does not match the bit pattern
10xxxxxx
, then a
UTFDataFormatException
 is thrown. Otherwise, the group is
converted to the character:
(char)(((a & 0x1F) << 6) | (b & 0x3F))
If the first byte of a group matches the bit pattern
1110xxxx
, then the group
consists of that byte
a
 and two more bytes
b
 and
c
. If there is no byte
c
 (because
byte
a
 was one of the last two of the bytes to be read), or either byte
b
 or byte
c
672






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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