Package java.nio.charset
| Class name | Description |
|---|---|
Charset | A named mapping between characters and bytes |
CharsetDecoder | Decodes bytes into characters |
CharsetEncoder | Encodes characters into bytes |
CoderResult | Describes coder results |
CodingErrorAction | Describes actions to take when coding errors are detected |
Acharset is named mapping between sequences of sixteen-bit Unicode characters and sequences of bytes, in the sense defined inRFC 2278. Adecoder is an engine which transforms bytes in a specific charset into characters, and anencoder is an engine which transforms characters into bytes. Encoders and decoders operate on byte and character buffers. They are collectively referred to ascoders.
TheCharset class defines methods for creating coders for a given charset and for retrieving the various names associated with a charset. It also defines static methods for testing whether a particular charset is supported, for locating charset instances by name, and for constructing a map that contains every charset for which support is available in the current Java virtual machine.
Most users will not use these classes directly; instead they will use the existing charset-related constructors and methods in theString class, together with the existingInputStreamReader andOutputStreamWriter classes, all of whose implementations have been reworked to make use of the charset facilities defined in this package. A small number of changes have been made to theInputStreamReader andOutputStreamWriter classes in order to allow explicit charset objects to be specified in the construction of instances of those classes.
Support for new charsets can be made available via the interface defined in theCharsetProvider class in thejava.nio.charset.spi package.
Unless otherwise noted, passing anull argument to a constructor or method in any class or interface in this package will cause aNullPointerException to be thrown.
- Since:
- 1.4
- External Specifications
- Related PackagesPackageDescriptionDefines buffers, which are containers for data, and provides an overview of the other NIO packages.Service-provider classes for the
java.nio.charsetpackage.Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.Defines interfaces and classes for the Java virtual machine to access files, file attributes, and file systems. - ClassDescriptionChecked exception thrown when a character encoding or decoding error occurs.A named mapping between sequences of sixteen-bit Unicodecode units and sequences of bytes.An engine that can transform a sequence of bytes in a specific charset into a sequence of sixteen-bit Unicode characters.An engine that can transform a sequence of sixteen-bit Unicode characters into a sequence of bytes in a specific charset.Error thrown when the
decodeLoopmethod of aCharsetDecoder, or theencodeLoopmethod of aCharsetEncoder, throws an unexpected exception.A description of the result state of a coder.A typesafe enumeration for coding-error actions.Unchecked exception thrown when a string that is not alegal charset name is used as such.Checked exception thrown when an input byte sequence is not legal for given charset, or an input character sequence is not a legal sixteen-bit Unicode sequence.Constant definitions for the standardcharsets.Checked exception thrown when an input character (or byte) sequence is valid but cannot be mapped to an output byte (or character) sequence.Unchecked exception thrown when no support is available for a requested charset.