This package contains classes that represent character sets or encodings, and defines methods that encode characters into bytes and decode bytes into characters . The key class is Charset , and you can obtain a Charset object for a named character encoding with the static forName( ) method. Charset defines encode( ) and decode( ) convenience methods, but for full control over the encoding and decoding process, you can also obtain a CharsetEncoder or CharsetDecoder object from the Charset . The Java platform has had a character encoding and decoding facility since Java 1.1, and defines a number of classes and methods that perform character encoding or decoding. Some of these classes and methods are specified to use the default charset for the locale; others take the name of a charset as a method or constructor argument. See, for example, the String( ) , java.io.InputStreamReader( ) and java.io.OutputStreamWriter( ) constructors. In Java 1.4, the java.nio.charset package defines a public API to the character encoding and decoding facility and allows applications to work with it explicitly. Most applications will not have to do this, however, and can simply continue to rely on the default charset, or can continue to supply charset names where needed. Even applications that use the java.nio.channels package can avoid explicit character encoding and decoding by passing the name of a desired charset to the newReader( ) and newWriter( ) methods of java.nio.channels.Channels . Classes public abstract class Charset implements Comparable<Charset>; public abstract class CharsetDecoder ; public abstract class CharsetEncoder ; public class CoderResult ; public class CodingErrorAction ; Exceptions public class CharacterCodingException extends java.io.IOException; public class MalformedInputException extends CharacterCodingException; public class UnmappableCharacterException extends CharacterCodingException; public class IllegalCharsetNameException extends IllegalArgumentException; public class UnsupportedCharsetException extends IllegalArgumentException; Errors public class CoderMalfunctionError extends Error; |