1/*
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26/**
27 * Defines buffers, which are containers for data, and provides an
28 * overview of the other NIO packages.
29 *
30 *
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
123 * features not found in the other buffer classes:
124 *
125 * <ul>
126 *
127 *   <li><p> A byte buffer can be allocated as a <a
128 *   href="ByteBuffer.html#direct"> <i>direct</i></a> buffer, in which
129 *   case the Java virtual machine will make a best effort to perform
130 *   native I/O operations directly upon it.  </p></li>
131 *
132 *   <li><p> A byte buffer can be created by {@link
133 *   java.nio.channels.FileChannel#map <i>mapping</i>} a region of a
134 *   file directly into memory, in which case a few additional
135 *   file-related operations defined in the {@link
136 *   java.nio.MappedByteBuffer} class are available.  </p></li>
137 *
138 *   <li><p> A byte buffer provides access to its content as either a
139 *   heterogeneous or homogeneous sequence of <a
140 *   href="ByteBuffer.html#bin"><i>binary data</i></a> of any
141 *   non-boolean primitive type, in either big-endian or little-endian
142 *   <a href="ByteOrder.html">byte order</a>.  </p></li>
143 *
144 * </ul>
145 *
146 * <p> Unless otherwise noted, passing a {@code null} argument to a
147 * constructor or method in any class or interface in this package
148 * will cause a {@link java.lang.NullPointerException
149 * NullPointerException} to be thrown.
150 *
151 * @since 1.4
152 * @author Mark Reinhold
153 * @author JSR-51 Expert Group
154 */
155package java.nio;
156