Path: blob/master/src/java.base/share/classes/java/nio/charset/package-info.java
41159 views
/*1* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/**26* Defines charsets, decoders, and encoders, for translating between27* bytes and Unicode characters.28*29* <table class="striped" style="margin-left:2em; text-align:left">30* <caption style="display:none">Summary of charsets, decoders, and encoders in this package</caption>31* <thead>32* <tr><th scope="col">Class name</th>33* <th scope="col">Description34* </thead>35* <tbody>36* <tr><th scope="row">{@link java.nio.charset.Charset}</th>37* <td>A named mapping between characters and bytes</td></tr>38* <tr><th scope="row">{@link java.nio.charset.CharsetDecoder}</th>39* <td>Decodes bytes into characters</td></tr>40* <tr><th scope="row">{@link java.nio.charset.CharsetEncoder}</th>41* <td>Encodes characters into bytes</td></tr>42* <tr><th scope="row">{@link java.nio.charset.CoderResult}</th>43* <td>Describes coder results</td></tr>44* <tr><th scope="row">{@link java.nio.charset.CodingErrorAction}</th>45* <td>Describes actions to take when coding errors are detected</td></tr>46* </tbody>47* </table>48*49* <p> A <i>charset</i> is named mapping between sequences of50* sixteen-bit Unicode characters and sequences of bytes, in the sense51* defined in <a52* href="http://www.ietf.org/rfc/rfc2278.txt"><i>RFC 2278</i></a>.53* A <i>decoder</i> is an engine which transforms bytes in a specific54* charset into characters, and an <i>encoder</i> is an engine which55* transforms characters into bytes. Encoders and decoders operate on56* byte and character buffers. They are collectively referred to as57* <i>coders</i>.58*59* <p> The {@link java.nio.charset.Charset} class defines methods for60* creating coders for a given charset and for retrieving the various61* names associated with a charset. It also defines static methods62* for testing whether a particular charset is supported, for locating63* charset instances by name, and for constructing a map that contains64* every charset for which support is available in the current Java65* virtual machine.66*67* <p> Most users will not use these classes directly; instead they68* will use the existing charset-related constructors and methods in69* the {@link java.lang.String} class, together with the existing70* {@link java.io.InputStreamReader} and {@link71* java.io.OutputStreamWriter} classes, all of whose implementations72* have been reworked to make use of the charset facilities defined in73* this package. A small number of changes have been made to the74* {@link java.io.InputStreamReader} and {@link75* java.io.OutputStreamWriter} classes in order to allow explicit76* charset objects to be specified in the construction of instances of77* those classes.78*79* <p> Support for new charsets can be made available via the80* interface defined in the {@link81* java.nio.charset.spi.CharsetProvider} class in the {@link82* java.nio.charset.spi} package.83*84* <p> Unless otherwise noted, passing a {@code null} argument to a85* constructor or method in any class or interface in this package86* will cause a {@link java.lang.NullPointerException87* NullPointerException} to be thrown.88*89*90* @since 1.491* @author Mark Reinhold92* @author JSR-51 Expert Group93*/94package java.nio.charset;959697