|
Section
11 : The java.io Package
Write
code that uses objects of the classes
InputStreamReader and OutputStreamWriter to translate
between Unicode and either platform default or ISO
8859-1 character encoding and Distinguish between
conditions under which platform default encoding
conversion should be used and conditions under which a
specific conversion should be used.
InputStreamReader and
OutputStreamWriter
These classes are
bridges between character streams and
byte streams.
InputStreamReader converts bytes into characters and
OutputStreamWriter translates characters written to it
into bytes.
Constructors:
-
InputStreamReader
(InputStream in)
-
InputStreamReader
(InputStream in, String encoding)
-
OutputStreamWriter
(OutputStream out)
-
OutputStreamWriter
(OutputStream out, String encoding)
The constructors, with
encoding as parameter, throw
UnsupportedEncodingException.
Methods of
InputStreamReader:
Methods of
OutputStreamWriter:
-
void close ()
-
void flush ()
-
String
getEncoding ()
-
void write (int c)
-
void write (char [] buffer,
int offset,
int length)
-
void write (String s,
int offset,
int length)
A
character encoding is a scheme for representing
characters. Java represents characters internally in
the 16 bit Unicode character encoding, but the host
platform may use different encoding scheme to
represent characters externally. If the default
encoding of the host platform is different than that
used by Java, then it becomes necessary to translate
the characters representation between these two
encoding schemes. In such cases, the encoding of the
platform may be specified to facilitate this
translation.
section11-1 | section11-2 | section11-3 | section11-4 | section11-5 | section11-6
Sections :
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11
If you wish to download the complete notes
(around 100 pages - pdf or doc file) for a small price, click here.
|