31 * <p> The central abstractions of the NIO APIs are: </p> 32 * 33 * <ul> 34 * 35 * <li><p> <a href="#buffers"><i>Buffers</i></a>, which are containers for data; 36 * </p></li> 37 * 38 * <li><p> <a 39 * href="charset/package-summary.html"><i>Charsets</i></a> and their 40 * associated <i>decoders</i> and <i>encoders</i>, <br> which 41 * translate between bytes and Unicode characters; </p></li> 42 * 43 * <li><p> <a 44 * href="channels/package-summary.html"><i>Channels</i></a> of 45 * various types, which represent connections <br> to entities 46 * capable of performing I/O operations; and </p></li> 47 * 48 * <li><p> <i>Selectors</i> and <i>selection keys</i>, which 49 * together with <br> <i>selectable channels</i> define a <a 50 * href="channels/package-summary.html#multiplex">multiplexed, 51 * non-blocking <br> I/O</a> facility. </p></li> 52 * 53 * </ul> 54 * 55 * <p> The {@code java.nio} package defines the buffer classes, which 56 * are used throughout the NIO APIs. The charset API is defined in 57 * the {@link java.nio.charset} package, and the channel and selector 58 * APIs are defined in the {@link java.nio.channels} package. Each of 59 * these subpackages has its own service-provider (SPI) subpackage, 60 * the contents of which can be used to extend the platform's default 61 * implementations or to construct alternative implementations. 62 * 63 * <a id="buffers"> </a> 64 * 65 * <blockquote><table class="borderless"> 66 * <caption style="display:none">Description of the various buffers</caption> 67 * <tr><th style="text-align:left">Buffers</th> 68 * <th style="text-align:left">Description</th></tr> 69 * <tr><td style="vertical-align:top">{@link java.nio.Buffer}</td> 70 * <td>Position, limit, and capacity; 71 * <br>clear, flip, rewind, and mark/reset</td></tr> 72 * <tr><td style="vertical-align:top"> {@link java.nio.ByteBuffer}</td> 73 * <td>Get/put, compact, views; allocate, wrap</td></tr> 74 * <tr><td style="vertical-align:top"> 75 * {@link java.nio.MappedByteBuffer} </td> 76 * <td>A byte buffer mapped to a file</td></tr> 77 * <tr><td style="vertical-align:top"> {@link java.nio.CharBuffer}</td> 78 * <td>Get/put, compact; allocate, wrap</td></tr> 79 * <tr><td style="vertical-align:top"> {@link java.nio.DoubleBuffer}</td> 80 * <td> ' '</td></tr> 81 * <tr><td style="vertical-align:top"> {@link java.nio.FloatBuffer}</td> 82 * <td> ' '</td></tr> 83 * <tr><td style="vertical-align:top"> {@link java.nio.IntBuffer}</td> 84 * <td> ' '</td></tr> 85 * <tr><td style="vertical-align:top"> {@link java.nio.LongBuffer}</td> 86 * <td> ' '</td></tr> 87 * <tr><td style="vertical-align:top"> {@link java.nio.ShortBuffer}</td> 88 * <td> ' '</td></tr> 89 * <tr><td style="vertical-align:top">{@link java.nio.ByteOrder}</td> 90 * <td>Typesafe enumeration for byte orders</td></tr> 91 * </table></blockquote> 92 * 93 * <p> A <i>buffer</i> is a container for a fixed amount of data of a 94 * specific primitive type. In addition to its content a buffer has a 95 * <i>position</i>, which is the index of the next element to be read 96 * or written, and a <i>limit</i>, which is the index of the first 97 * element that should not be read or written. The base {@link 98 * java.nio.Buffer} class defines these properties as well as methods 99 * for <i>clearing</i>, <i>flipping</i>, and <i>rewinding</i>, for 100 * <i>marking</i> the current position, and for <i>resetting</i> the 101 * position to the previous mark. 102 * 103 * <p> There is a buffer class for each non-boolean primitive type. 104 * Each class defines a family of <i>get</i> and <i>put</i> methods 105 * for moving data out of and in to a buffer, methods for 106 * <i>compacting</i>, <i>duplicating</i>, and <i>slicing</i> a buffer, 107 * and static methods for <i>allocating</i> a new buffer as well as 108 * for <i>wrapping</i> an existing array into a buffer. 109 * 110 * <p> Byte buffers are distinguished in that they can be used as the 111 * sources and targets of I/O operations. They also support several | 31 * <p> The central abstractions of the NIO APIs are: </p> 32 * 33 * <ul> 34 * 35 * <li><p> <a href="#buffers"><i>Buffers</i></a>, which are containers for data; 36 * </p></li> 37 * 38 * <li><p> <a 39 * href="charset/package-summary.html"><i>Charsets</i></a> and their 40 * associated <i>decoders</i> and <i>encoders</i>, <br> which 41 * translate between bytes and Unicode characters; </p></li> 42 * 43 * <li><p> <a 44 * href="channels/package-summary.html"><i>Channels</i></a> of 45 * various types, which represent connections <br> to entities 46 * capable of performing I/O operations; and </p></li> 47 * 48 * <li><p> <i>Selectors</i> and <i>selection keys</i>, which 49 * together with <br> <i>selectable channels</i> define a <a 50 * href="channels/package-summary.html#multiplex">multiplexed, 51 * non-blocking <br> I/O</a> facility. </p></li> 52 * 53 * </ul> 54 * 55 * <p> The {@code java.nio} package defines the buffer classes, which 56 * are used throughout the NIO APIs. The charset API is defined in 57 * the {@link java.nio.charset} package, and the channel and selector 58 * APIs are defined in the {@link java.nio.channels} package. Each of 59 * these subpackages has its own service-provider (SPI) subpackage, 60 * the contents of which can be used to extend the platform's default 61 * implementations or to construct alternative implementations. 62 * 63 * <a id="buffers"> </a> 64 * 65 * <table class="striped" style="margin-left:2em; text-align:left"> 66 * <caption style="display:none">Description of the various buffers</caption> 67 * <thead> 68 * <tr><th scope="col">Buffers</th> 69 * <th scope="col">Description</th></tr> 70 * </thead> 71 * <tbody> 72 * <tr><th scope="row">{@link java.nio.Buffer}</th> 73 * <td>Position, limit, and capacity; 74 * clear, flip, rewind, and mark/reset</td></tr> 75 * <tr><th scope="row"> 76 * <span style="padding-left:1em">{@link java.nio.ByteBuffer}</span></th> 77 * <td>Get/put, compact, views; allocate, wrap</td></tr> 78 * <tr><th scope="row"> 79 * <span style="padding-left:2em">{@link java.nio.MappedByteBuffer}</span></th> 80 * <td>A byte buffer mapped to a file</td></tr> 81 * <tr><th scope="row"> 82 * <span style="padding-left:1em">{@link java.nio.CharBuffer}</span></th> 83 * <td>Get/put, compact; allocate, wrap</td></tr> 84 * <tr><th scope="row"> 85 * <span style="padding-left:1em">{@link java.nio.DoubleBuffer}</span></th> 86 * <td>Get/put, compact; allocate, wrap</td></tr> 87 * <tr><th scope="row"> 88 * <span style="padding-left:1em">{@link java.nio.FloatBuffer}</span></th> 89 * <td>Get/put, compact; allocate, wrap</td></tr> 90 * <tr><th scope="row"> 91 * <span style="padding-left:1em">{@link java.nio.IntBuffer}</span></th> 92 * <td>Get/put, compact; allocate, wrap</td></tr> 93 * <tr><th scope="row"> 94 * <span style="padding-left:1em">{@link java.nio.LongBuffer}</span></th> 95 * <td>Get/put, compact; allocate, wrap</td></tr> 96 * <tr><th scope="row"> 97 * <span style="padding-left:1em">{@link java.nio.ShortBuffer}</span></th> 98 * <td>Get/put, compact; allocate, wrap</td></tr> 99 * <tr><th scope="row">{@link java.nio.ByteOrder}</th> 100 * <td>Typesafe enumeration for byte orders</td></tr> 101 * </tbody> 102 * </table> 103 * 104 * <p> A <i>buffer</i> is a container for a fixed amount of data of a 105 * specific primitive type. In addition to its content a buffer has a 106 * <i>position</i>, which is the index of the next element to be read 107 * or written, and a <i>limit</i>, which is the index of the first 108 * element that should not be read or written. The base {@link 109 * java.nio.Buffer} class defines these properties as well as methods 110 * for <i>clearing</i>, <i>flipping</i>, and <i>rewinding</i>, for 111 * <i>marking</i> the current position, and for <i>resetting</i> the 112 * position to the previous mark. 113 * 114 * <p> There is a buffer class for each non-boolean primitive type. 115 * Each class defines a family of <i>get</i> and <i>put</i> methods 116 * for moving data out of and in to a buffer, methods for 117 * <i>compacting</i>, <i>duplicating</i>, and <i>slicing</i> a buffer, 118 * and static methods for <i>allocating</i> a new buffer as well as 119 * for <i>wrapping</i> an existing array into a buffer. 120 * 121 * <p> Byte buffers are distinguished in that they can be used as the 122 * sources and targets of I/O operations. They also support several |