Class | Description |
---|---|
Buffer |
A container for data of a specific primitive type.
|
ByteBuffer |
A byte buffer.
|
ByteOrder |
A typesafe enumeration for byte orders.
|
FloatBuffer |
A float buffer.
|
IntBuffer |
An int buffer.
|
ShortBuffer |
A short buffer.
|
Exception | Description |
---|---|
BufferOverflowException |
Unchecked exception thrown when a relative put operation reaches
the target buffer's limit.
|
BufferUnderflowException |
Unchecked exception thrown when a relative get operation reaches
the source buffer's limit.
|
The NIO Buffer API subset consists of portions
of the Buffer
, ByteBuffer
,
ShortBuffer
, IntBuffer
, and
FloatBuffer
classes as well as the support classes
BufferOverflowException
, and
BufferUnderflowException
.
Only basic buffer functionality is supported, and does not
include mapped buffers, charsets, or selectors,
read-only buffers, mark, reset, and rewind.
Primitive data types are supported
only for byte
, short
, int
, and float
.
No support is provided for data types char
, long
, or
double
.
The central abstractions of the NIO APIs are:
Buffers, which are containers for data.
Channels of
various types, which represent connections
to entities capable of
performing I/O operations
The java.nio package defines the buffer classes, which are used throughout the NIO APIs.
Buffers Description Buffer
Position, limit, and capacity;
clear, and flipByteBuffer
Get/put, views; allocate, wrap FloatBuffer
Get/put, views; wrap IntBuffer
Get/put, views; wrap ShortBuffer
Get/put, views; wrap
A buffer is a container for a fixed amount of data of a specific
primitive type. In addition to its content a buffer has a position,
which is the index of the next element to be read or written, and a
limit, which is the index of the first element that should not be read
or written. The base Buffer
class defines these properties as
well as methods for clearing, flipping, and rewinding.
There is a buffer class for each non-boolean primitive type. Each class defines a family of get and put methods for moving data out of and in to a buffer, methods for slicing a buffer, and static methods for wrapping an existing array into a buffer.
Byte buffers support several features not found in the other buffer classes:
A byte buffer can be allocated as a direct buffer, in which case the Java virtual machine will make a best effort to perform native I/O operations directly upon it.
A byte buffer provides access to its content as either a heterogeneous or homogeneous sequence of binary data of any non-boolean primitive type, in platform byte order.
Unless otherwise noted, passing a null argument to a constructor
or method in any class or interface in this package will cause a NullPointerException
to be thrown.
Note: Unlike their Java SE8 counterparts, the CLDC8 versions of ByteBuffer
,
ShortBuffer
, IntBuffer
and FloatBuffer
are not abstract
but are concrete classes.
Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. Use of this specification is subject to license terms.