src/share/classes/java/nio/charset/package.html

Print this page




  31 Defines charsets, decoders, and encoders, for translating between bytes and
  32 Unicode characters.
  33 
  34 <blockquote><table cellspacing=1 cellpadding=0 summary="Summary of charsets, decoders, and encoders in this package">
  35  <tr><th><p align="left">Class name</p></th><th><p align="left">Description</p></th></tr>
  36   <tr><td valign=top><tt>{@link java.nio.charset.Charset}</tt></td>
  37       <td>A named mapping between characters<br>and bytes</td></tr>
  38   <tr><td valign=top><tt>{@link java.nio.charset.CharsetDecoder}</tt></td>
  39       <td>Decodes bytes into characters</td></tr>
  40   <tr><td valign=top><tt>{@link java.nio.charset.CharsetEncoder}&nbsp;&nbsp;</tt></td>
  41       <td>Encodes characters into bytes</td></tr>
  42   <tr><td valign=top><tt>{@link java.nio.charset.CoderResult}&nbsp;&nbsp;</tt></td>
  43       <td>Describes coder results</td></tr>
  44   <tr><td valign=top><tt>{@link java.nio.charset.CodingErrorAction}&nbsp;&nbsp;</tt></td>
  45       <td>Describes actions to take when<br>coding errors are detected</td></tr>
  46 
  47 </table></blockquote>
  48 
  49 <p> A <i>charset</i> is named mapping between sequences of sixteen-bit Unicode
  50 characters and sequences of bytes, in the sense defined in <a
  51 href="http://ietf.org/rfc/rfc2278.txt"><i>RFC&nbsp;2278</i></a>.  A
  52 <i>decoder</i> is an engine which transforms bytes in a specific charset into
  53 characters, and an <i>encoder</i> is an engine which transforms characters into
  54 bytes.  Encoders and decoders operate on byte and character buffers.  They are
  55 collectively referred to as <i>coders</i>.
  56 
  57 <p> The {@link java.nio.charset.Charset} class defines methods for creating
  58 coders for a given charset and for retrieving the various names associated with
  59 a charset.  It also defines static methods for testing whether a particular
  60 charset is supported, for locating charset instances by name, and for
  61 constructing a map that contains every charset for which support is available
  62 in the current Java virtual machine.
  63 
  64 <p> Most users will not use these classes directly; instead they will use the
  65 existing charset-related constructors and methods in the {@link
  66 java.lang.String} class, together with the existing {@link
  67 java.io.InputStreamReader} and {@link java.io.OutputStreamWriter} classes, all
  68 of whose implementations have been reworked to make use of the charset
  69 facilities defined in this package.  A small number of changes have been made
  70 to the {@link java.io.InputStreamReader} and {@link java.io.OutputStreamWriter}
  71 classes in order to allow explicit charset objects to be specified in the


  31 Defines charsets, decoders, and encoders, for translating between bytes and
  32 Unicode characters.
  33 
  34 <blockquote><table cellspacing=1 cellpadding=0 summary="Summary of charsets, decoders, and encoders in this package">
  35  <tr><th><p align="left">Class name</p></th><th><p align="left">Description</p></th></tr>
  36   <tr><td valign=top><tt>{@link java.nio.charset.Charset}</tt></td>
  37       <td>A named mapping between characters<br>and bytes</td></tr>
  38   <tr><td valign=top><tt>{@link java.nio.charset.CharsetDecoder}</tt></td>
  39       <td>Decodes bytes into characters</td></tr>
  40   <tr><td valign=top><tt>{@link java.nio.charset.CharsetEncoder}&nbsp;&nbsp;</tt></td>
  41       <td>Encodes characters into bytes</td></tr>
  42   <tr><td valign=top><tt>{@link java.nio.charset.CoderResult}&nbsp;&nbsp;</tt></td>
  43       <td>Describes coder results</td></tr>
  44   <tr><td valign=top><tt>{@link java.nio.charset.CodingErrorAction}&nbsp;&nbsp;</tt></td>
  45       <td>Describes actions to take when<br>coding errors are detected</td></tr>
  46 
  47 </table></blockquote>
  48 
  49 <p> A <i>charset</i> is named mapping between sequences of sixteen-bit Unicode
  50 characters and sequences of bytes, in the sense defined in <a
  51 href="http://www.ietf.org/rfc/rfc2278.txt"><i>RFC&nbsp;2278</i></a>.  A
  52 <i>decoder</i> is an engine which transforms bytes in a specific charset into
  53 characters, and an <i>encoder</i> is an engine which transforms characters into
  54 bytes.  Encoders and decoders operate on byte and character buffers.  They are
  55 collectively referred to as <i>coders</i>.
  56 
  57 <p> The {@link java.nio.charset.Charset} class defines methods for creating
  58 coders for a given charset and for retrieving the various names associated with
  59 a charset.  It also defines static methods for testing whether a particular
  60 charset is supported, for locating charset instances by name, and for
  61 constructing a map that contains every charset for which support is available
  62 in the current Java virtual machine.
  63 
  64 <p> Most users will not use these classes directly; instead they will use the
  65 existing charset-related constructors and methods in the {@link
  66 java.lang.String} class, together with the existing {@link
  67 java.io.InputStreamReader} and {@link java.io.OutputStreamWriter} classes, all
  68 of whose implementations have been reworked to make use of the charset
  69 facilities defined in this package.  A small number of changes have been made
  70 to the {@link java.io.InputStreamReader} and {@link java.io.OutputStreamWriter}
  71 classes in order to allow explicit charset objects to be specified in the