jdk/src/share/classes/java/nio/package.html
author yan
Mon, 18 Nov 2013 17:00:23 +0400
changeset 21801 b8a5ff5f0c2a
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
8028049: Tidy warnings cleanup for packages java.nio/java.io Reviewed-by: alanb, darcy Contributed-by: Sergey Lugovoy <sergey.lugovoy@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
<!--
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
-->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
<!doctype html public "-//IETF//DTD HTML//EN">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
<html>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
<body bgcolor="white">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
Defines buffers, which are containers for data, and provides an overview of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
other NIO packages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
<p> The central abstractions of the NIO APIs are: </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  <li><p> <a href="#buffers"><i>Buffers</i></a>, which are containers for data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  </p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  <li><p> <a href="charset/package-summary.html"><i>Charsets</i></a> and their
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  associated <i>decoders</i> and <i>encoders</i>, <br> which translate between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  bytes and Unicode characters; </p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  <li><p> <a href="channels/package-summary.html"><i>Channels</i></a> of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  various types, which represent connections <br> to entities capable of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  performing I/O operations; and </p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  <li><p> <i>Selectors</i> and <i>selection keys</i>, which together with <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  <i>selectable channels</i> define a <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  href="channels/package-summary.html#multiplex">multiplexed, non-blocking <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  I/O</a>&nbsp;facility.  </p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
<p> The <tt>java.nio</tt> package defines the buffer classes, which are used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
throughout the NIO APIs.  The charset API is defined in the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
java.nio.charset} package, and the channel and selector APIs are defined in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
{@link java.nio.channels} package.  Each of these subpackages has its own
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
service-provider (SPI) subpackage, the contents of which can be used to extend
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
the platform's default implementations or to construct alternative
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
21801
b8a5ff5f0c2a 8028049: Tidy warnings cleanup for packages java.nio/java.io
yan
parents: 5506
diff changeset
    65
<a name="buffers"> </a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
<blockquote><table cellspacing=1 cellpadding=0 summary="Description of the various buffers">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  <tr><th><p align="left">Buffers</p></th><th><p align="left">Description</p></th></tr> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  <tr><td valign=top><tt>{@link java.nio.Buffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
      <td>Position, limit, and capacity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
          <br>clear, flip, rewind, and mark/reset</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.ByteBuffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
      <td>Get/put, compact, views; allocate,&nbsp;wrap</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  <tr><td valign=top><tt>&nbsp;&nbsp;&nbsp;&nbsp;{@link java.nio.MappedByteBuffer}&nbsp;&nbsp;</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
      <td>A byte buffer mapped to a file</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.CharBuffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
      <td>Get/put, compact; allocate,&nbsp;wrap</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.DoubleBuffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.FloatBuffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.IntBuffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.LongBuffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
      <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  <tr><td valign=top><tt>&nbsp;&nbsp;{@link java.nio.ShortBuffer}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
      <td>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;'</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  <tr><td valign=top><tt>{@link java.nio.ByteOrder}</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
      <td>Typesafe enumeration for&nbsp;byte&nbsp;orders</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
</table></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
<p> A <i>buffer</i> is a container for a fixed amount of data of a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
primitive type.  In addition to its content a buffer has a <i>position</i>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
which is the index of the next element to be read or written, and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
<i>limit</i>, which is the index of the first element that should not be read
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
or written.  The base {@link java.nio.Buffer} class defines these properties as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
well as methods for <i>clearing</i>, <i>flipping</i>, and <i>rewinding</i>, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
<i>marking</i> the current position, and for <i>resetting</i> the position to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
the previous mark.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
<p> There is a buffer class for each non-boolean primitive type.  Each class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
defines a family of <i>get</i> and <i>put</i> methods for moving data out of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
and in to a buffer, methods for <i>compacting</i>, <i>duplicating</i>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
<i>slicing</i> a buffer, and static methods for <i>allocating</i> a new buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
as well as for <i>wrapping</i> an existing array into a buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
<p> Byte buffers are distinguished in that they can be used as the sources and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
targets of I/O operations.  They also support several features not found in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
other buffer classes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  <li><p> A byte buffer can be allocated as a <a href="ByteBuffer.html#direct">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  <i>direct</i></a> buffer, in which case the Java virtual machine will make a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  best effort to perform native I/O operations directly upon it.  </p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  <li><p> A byte buffer can be created by {@link
21801
b8a5ff5f0c2a 8028049: Tidy warnings cleanup for packages java.nio/java.io
yan
parents: 5506
diff changeset
   118
  java.nio.channels.FileChannel#map <i>mapping</i>} a region of a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  file directly into memory, in which case a few additional file-related
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  operations defined in the {@link java.nio.MappedByteBuffer} class are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
  available.  </p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
  <li><p> A byte buffer provides access to its content as either a heterogeneous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  or homogeneous sequence of <a href="ByteBuffer.html#bin">binary data</i></a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
  of any non-boolean primitive type, in either big-endian or little-endian <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  href="ByteOrder.html">byte order</a>.  </p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
<p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
or method in any class or interface in this package will cause a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
java.lang.NullPointerException NullPointerException} to be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
@since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
@author Mark Reinhold
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
@author JSR-51 Expert Group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
</body>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
</html>