10139N/A Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved. 10139N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 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 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. 11256N/A Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 11358N/A<!
doctype html public "-//IETF//DTD HTML//EN">
11358N/ADefines buffers, which are containers for data, and provides an overview of the
14126N/A<
p> The central abstractions of the NIO APIs are: </
p>
13907N/A <
li><
p> <
a href="#buffers"><
i>Buffers</
i></
a>, which are containers for data;
15503N/A associated <
i>decoders</
i> and <
i>encoders</
i>, <
br> which translate between
16427N/A bytes and Unicode characters; </
p></
li>
16353N/A various types, which represent connections <
br> to entities capable of
16193N/A performing I/O operations; and </
p></
li>
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 16623N/A I/O</
a> facility. </
p></
li>
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/Aservice-provider (SPI) subpackage, the contents of which can be used to extend
10139N/Athe platform's default implementations or to construct alternative
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 <
td>Position, limit, and capacity;
10139N/A <
td>A byte buffer mapped to a file</
td></
tr>
10139N/A <
td> ' '</
td></
tr>
10139N/A <
td> ' '</
td></
tr>
10139N/A <
td> ' '</
td></
tr>
10139N/A <
td> ' '</
td></
tr>
10139N/A <
td> ' '</
td></
tr>
10139N/A <
td>Typesafe enumeration for byte orders</
td></
tr>
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/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/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<
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
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>
10142N/A <
li><
p> A byte buffer can be created by {@link
16395N/A file directly into memory, in which case a few additional file-related
10139N/A <
li><
p> A byte buffer provides access to its content as either a heterogeneous
11358N/A of any non-boolean primitive type, in either big-endian or little-endian <
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