package.html revision 0
10139N/A<!--
10139N/A Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
10139N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12151N/A
10139N/A This code is free software; you can redistribute it and/or modify it
10139N/A under the terms of the GNU General Public License version 2 only, as
10139N/A published by the Free Software Foundation. Sun designates this
10139N/A particular file as subject to the "Classpath" exception as provided
10139N/A by Sun in the LICENSE file that accompanied this code.
10139N/A
10139N/A This code is distributed in the hope that it will be useful, but WITHOUT
15322N/A ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10139N/A FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14030N/A version 2 for more details (a copy is included in the LICENSE file that
14030N/A accompanied this code).
16193N/A
12578N/A You should have received a copy of the GNU General Public License version
10139N/A 2 along with this work; if not, write to the Free Software Foundation,
10139N/A Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10139N/A
11256N/A Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
10142N/A CA 95054 USA or visit www.sun.com if you need additional information or
12773N/A have any questions.
12773N/A-->
12773N/A
11358N/A<!doctype html public "-//IETF//DTD HTML//EN">
10139N/A<html>
11358N/A<body bgcolor="white">
11358N/A
11358N/ADefines buffers, which are containers for data, and provides an overview of the
11358N/Aother NIO packages.
11358N/A
11358N/A
14126N/A<p> The central abstractions of the NIO APIs are: </p>
11002N/A
15503N/A<ul>
13025N/A
13907N/A <li><p> <a href="#buffers"><i>Buffers</i></a>, which are containers for data;
13907N/A </p></li>
15460N/A
15460N/A <li><p> <a href="charset/package-summary.html"><i>Charsets</i></a> and their
15503N/A associated <i>decoders</i> and <i>encoders</i>, <br> which translate between
16427N/A bytes and Unicode characters; </p></li>
15543N/A
15968N/A <li><p> <a href="channels/package-summary.html"><i>Channels</i></a> of
16353N/A various types, which represent connections <br> to entities capable of
16193N/A performing I/O operations; and </p></li>
16054N/A
16193N/A <li><p> <i>Selectors</i> and <i>selection keys</i>, which together with <br>
16511N/A <i>selectable channels</i> define a <a
16511N/A href="channels/package-summary.html#multiplex">multiplexed, non-blocking <br>
16623N/A I/O</a>&nbsp;facility. </p></li>
16623N/A
10139N/A</ul>
10139N/A
10139N/A<p> The <tt>java.nio</tt> package defines the buffer classes, which are used
10139N/Athroughout the NIO APIs. The charset API is defined in the {@link
10139N/Ajava.nio.charset} package, and the channel and selector APIs are defined in the
10139N/A{@link java.nio.channels} package. Each of these subpackages has its own
10139N/Aservice-provider (SPI) subpackage, the contents of which can be used to extend
10139N/Athe platform's default implementations or to construct alternative
10139N/Aimplementations.
10139N/A
10139N/A
10139N/A<a name="buffers">
10139N/A
10139N/A<blockquote><table cellspacing=1 cellpadding=0 summary="Description of the various buffers">
10139N/A <tr><th><p align="left">Buffers</p></th><th><p align="left">Description</p></th></tr>
10139N/A <tr><td valign=top><tt>{@link java.nio.Buffer}</tt></td>
10139N/A <td>Position, limit, and capacity;
10139N/A <br>clear, flip, rewind, and mark/reset</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.ByteBuffer}</tt></td>
10139N/A <td>Get/put, compact, views; allocate,&nbsp;wrap</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;&nbsp;&nbsp;{@link java.nio.MappedByteBuffer}&nbsp;&nbsp;</tt></td>
10139N/A <td>A byte buffer mapped to a file</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.CharBuffer}</tt></td>
10139N/A <td>Get/put, compact; allocate,&nbsp;wrap</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.DoubleBuffer}</tt></td>
10139N/A <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.FloatBuffer}</tt></td>
10139N/A <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.IntBuffer}</tt></td>
10139N/A <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.LongBuffer}</tt></td>
10139N/A <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
10139N/A <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.ShortBuffer}</tt></td>
10139N/A <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
10139N/A <tr><td valign=top><tt>{@link java.nio.ByteOrder}</tt></td>
10139N/A <td>Typesafe enumeration for&nbsp;byte&nbsp;orders</td></tr>
10139N/A</table></blockquote>
10139N/A
10139N/A<p> A <i>buffer</i> is a container for a fixed amount of data of a specific
10139N/Aprimitive type. In addition to its content a buffer has a <i>position</i>,
10139N/Awhich is the index of the next element to be read or written, and a
10139N/A<i>limit</i>, which is the index of the first element that should not be read
10139N/Aor written. The base {@link java.nio.Buffer} class defines these properties as
10139N/Awell as methods for <i>clearing</i>, <i>flipping</i>, and <i>rewinding</i>, for
10139N/A<i>marking</i> the current position, and for <i>resetting</i> the position to
10139N/Athe previous mark.
10139N/A
10139N/A<p> There is a buffer class for each non-boolean primitive type. Each class
10139N/Adefines a family of <i>get</i> and <i>put</i> methods for moving data out of
10139N/Aand in to a buffer, methods for <i>compacting</i>, <i>duplicating</i>, and
10139N/A<i>slicing</i> a buffer, and static methods for <i>allocating</i> a new buffer
10139N/Aas well as for <i>wrapping</i> an existing array into a buffer.
10139N/A
10139N/A<p> Byte buffers are distinguished in that they can be used as the sources and
10139N/Atargets of I/O operations. They also support several features not found in the
12274N/Aother buffer classes:
12274N/A
12274N/A<ul>
12274N/A
10139N/A <li><p> A byte buffer can be allocated as a <a href="ByteBuffer.html#direct">
10139N/A <i>direct</i></a> buffer, in which case the Java virtual machine will make a
10139N/A best effort to perform native I/O operations directly upon it. </p></li>
10139N/A
10142N/A <li><p> A byte buffer can be created by {@link
10139N/A java.nio.channels.FileChannel#map </code><i>mapping</i><code>} a region of a
16395N/A file directly into memory, in which case a few additional file-related
16395N/A operations defined in the {@link java.nio.MappedByteBuffer} class are
10139N/A available. </p></li>
11358N/A
10139N/A <li><p> A byte buffer provides access to its content as either a heterogeneous
11358N/A or homogeneous sequence of <a href="ByteBuffer.html#bin">binary data</i></a>
11358N/A of any non-boolean primitive type, in either big-endian or little-endian <a
11358N/A href="ByteOrder.html">byte order</a>. </p></li>
11358N/A
11002N/A</ul>
13025N/A
12830N/A<p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
13664N/Aor method in any class or interface in this package will cause a {@link
16425N/Ajava.lang.NullPointerException NullPointerException} to be thrown.
15591N/A
16193N/A@since 1.4
16511N/A@author Mark Reinhold
16623N/A@author JSR-51 Expert Group
10139N/A
10139N/A</body>
10139N/A</html>
10139N/A