<s>
java.nio	B-Language
(	O
NIO	O
stands	O
for	O
New	O
Input/Output	B-General_Concept
)	O
is	O
a	O
collection	O
of	O
Java	B-Language
programming	I-Language
language	I-Language
APIs	B-Application
that	O
offer	O
features	O
for	O
intensive	O
I/O	B-General_Concept
operations	I-General_Concept
.	O
</s>
<s>
It	O
was	O
introduced	O
with	O
the	O
J2SE	B-Language
1.4	O
release	O
of	O
Java	B-Language
by	O
Sun	O
Microsystems	O
to	O
complement	O
an	O
existing	O
standard	O
I/O	B-General_Concept
.	O
</s>
<s>
NIO	O
was	O
developed	O
under	O
the	O
Java	B-Language
Community	I-Language
Process	I-Language
as	O
JSR	B-Language
51	I-Language
.	O
</s>
<s>
An	O
extension	O
to	O
NIO	O
that	O
offers	O
a	O
new	O
file	B-Application
system	I-Application
API	B-Application
,	O
called	O
NIO.2	O
,	O
was	O
released	O
with	O
Java	B-Language
SE	I-Language
7	O
(	O
"	O
Dolphin	O
"	O
)	O
.	O
</s>
<s>
The	O
APIs	B-Application
of	O
NIO	O
were	O
designed	O
to	O
provide	O
access	O
to	O
the	O
low-level	O
I/O	B-General_Concept
operations	I-General_Concept
of	O
modern	O
operating	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
Although	O
the	O
APIs	B-Application
are	O
themselves	O
relatively	O
high-level	O
,	O
the	O
intent	O
is	O
to	O
facilitate	O
an	O
implementation	O
that	O
can	O
directly	O
use	O
the	O
most	O
efficient	O
operations	O
of	O
the	O
underlying	O
platform	O
.	O
</s>
<s>
The	O
Java	B-Language
NIO	I-Language
APIs	B-Application
are	O
provided	O
in	O
the	O
package	O
and	O
its	O
subpackages	O
.	O
</s>
<s>
The	O
documentation	O
by	O
Oracle	B-Application
identifies	O
these	O
features	O
.	O
</s>
<s>
Although	O
theoretically	O
these	O
are	O
general-purpose	O
data	O
structures	O
,	O
the	O
implementation	O
may	O
select	O
memory	O
for	O
alignment	O
or	O
paging	O
characteristics	O
,	O
which	O
are	O
not	O
otherwise	O
accessible	O
in	O
Java	B-Language
.	O
</s>
<s>
Typically	O
,	O
this	O
would	O
be	O
used	O
to	O
allow	O
the	O
buffer	O
contents	O
to	O
occupy	O
the	O
same	O
physical	O
memory	O
used	O
by	O
the	O
underlying	O
operating	B-General_Concept
system	I-General_Concept
for	O
its	O
native	O
I/O	B-General_Concept
operations	I-General_Concept
,	O
thus	O
allowing	O
the	O
most	O
direct	O
transfer	O
mechanism	O
,	O
and	O
eliminating	O
the	O
need	O
for	O
any	O
additional	O
copying	O
.	O
</s>
<s>
In	O
most	O
operating	B-General_Concept
systems	I-General_Concept
,	O
provided	O
the	O
particular	O
area	O
of	O
memory	O
has	O
the	O
right	O
properties	O
,	O
transfer	O
can	O
take	O
place	O
without	O
using	O
the	O
CPU	O
at	O
all	O
.	O
</s>
<s>
There	O
are	O
buffer	O
classes	O
for	O
all	O
of	O
Java	B-Language
's	O
primitive	O
types	O
except	O
boolean	O
,	O
which	O
can	O
share	O
memory	O
with	O
byte	O
buffers	O
and	O
allow	O
arbitrary	O
interpretation	O
of	O
the	O
underlying	O
bytes	O
.	O
</s>
<s>
This	O
is	O
a	O
low-level	O
data	O
transfer	O
mechanism	O
that	O
exists	O
in	O
parallel	O
with	O
the	O
classes	O
of	O
the	O
higher-level	O
I/O	B-General_Concept
library	O
(	O
packages	O
and	O
)	O
.	O
</s>
<s>
Channels	O
are	O
analogous	O
to	O
"	O
file	B-Application
descriptors	I-Application
"	O
found	O
in	O
Unix-like	O
operating	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
File	B-Operating_System
channels	O
(	O
)	O
can	O
use	O
arbitrary	O
buffers	O
but	O
can	O
also	O
establish	O
a	O
buffer	O
directly	O
mapped	O
to	O
file	B-Operating_System
contents	O
using	O
memory-mapped	B-General_Concept
file	I-General_Concept
.	O
</s>
<s>
They	O
can	O
also	O
interact	O
with	O
file	B-Application
system	I-Application
locks	O
.	O
</s>
<s>
Similarly	O
,	O
socket	B-Protocol
channels	O
(	O
and	O
)	O
allow	O
for	O
data	O
transfer	O
between	O
sockets	O
and	O
NIO	O
buffers	O
.	O
</s>
<s>
FileChannel	O
can	O
be	O
used	O
to	O
do	O
a	O
file	B-Operating_System
copy	O
,	O
which	O
is	O
potentially	O
far	O
more	O
efficient	O
than	O
using	O
old	O
read/write	O
with	O
a	O
byte	O
array	O
.	O
</s>
<s>
Although	O
this	O
multiplexing	B-Architecture
behavior	O
could	O
be	O
implemented	O
with	O
threads	O
,	O
the	O
selector	O
can	O
provide	O
a	O
significantly	O
more	O
efficient	O
implementation	O
using	O
lower-level	O
operating	B-General_Concept
system	I-General_Concept
constructs	O
.	O
</s>
<s>
A	O
POSIX-compliant	O
operating	B-General_Concept
system	I-General_Concept
,	O
for	O
example	O
,	O
would	O
have	O
direct	O
representations	O
of	O
these	O
concepts	O
,	O
select( )	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
a	O
character	B-General_Concept
set	I-General_Concept
is	O
a	O
mapping	O
between	O
Unicode	O
characters	O
(	O
or	O
a	O
subset	O
of	O
them	O
)	O
and	O
bytes	O
.	O
</s>
<s>
The	O
package	O
of	O
NIO	O
provides	O
facilities	O
for	O
identifying	O
character	B-General_Concept
sets	I-General_Concept
and	O
providing	O
encoding	O
and	O
decoding	O
algorithms	O
for	O
new	O
mappings	O
.	O
</s>
<s>
It	O
is	O
unexpected	O
that	O
a	O
Channel	O
associated	O
with	O
a	O
Java	B-Language
IO	O
RandomAccess	O
file	B-Operating_System
closes	O
the	O
file	B-Application
descriptor	I-Application
on	O
an	O
interrupt	O
,	O
whereas	O
RandomAccessFiles	O
own	O
read	O
method	O
does	O
not	O
do	O
this	O
.	O
</s>
<s>
JDK	O
7	O
includes	O
a	O
package	O
which	O
,	O
with	O
the	O
class	O
(	O
also	O
new	O
to	O
JDK	O
7	O
)	O
,	O
among	O
other	O
features	O
,	O
provides	O
extended	O
capabilities	O
for	O
filesystem	B-Application
tasks	O
,	O
e.g.	O
</s>
<s>
can	O
work	O
with	O
symbolic/hard	O
links	O
and	O
dump	O
big	O
directory	O
listings	O
into	O
buffers	O
more	O
quickly	O
than	O
the	O
old	O
File	B-Operating_System
class	O
does	O
.	O
</s>
<s>
The	O
package	O
and	O
its	O
related	O
package	O
,	O
,	O
provide	O
comprehensive	O
support	O
for	O
file	B-Operating_System
I/O	B-General_Concept
and	O
for	O
accessing	O
the	O
file	B-Application
system	I-Application
.	O
</s>
<s>
A	O
zip	O
file	B-Application
system	I-Application
provider	O
is	O
also	O
available	O
in	O
JDK	O
7	O
.	O
</s>
