Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Non-blocking I/O (Java)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Usage==== NIO buffers maintain several pointers that dictate the function of their accessor methods. The NIO buffer implementation contains a rich set of methods for modifying these pointers: * The <code>flip()</code> method, rather than performing a "flip" or paging function in the canonical sense, moves the ''position'' pointer to the origin of the underlying array (if any) and the ''limit'' pointer to the former position of the ''position'' pointer. * Three <code>get()</code> methods are supplied for transferring data out of a NIO buffer. The bulk implementation, rather than performing a "get" in the traditional sense, "puts" the data into a specified array. The "offset" argument supplied to this method refers not to the offset from within the buffer from which to read, nor an offset from the ''position'' pointer, but rather the offset from 0 within the target array. * Unless using the absolute <code>get()</code> and <code>put()</code> methods, any <code>get()</code> or <code>put()</code> is conducted from the ''position'' pointer. Should one need to read from a different position within the underlying array, whilst not adjusting the ''writing'' position, the <code>mark()</code> and <code>reset()</code> methods have been supplied. * The <code>mark()</code> method effectively stores the position of the ''position'' pointer by setting the ''mark'' pointer to the position of the ''position'' pointer. The <code>reset()</code> method causes the ''position'' pointer to move to the ''mark'' pointer's position. * Upon invocation of the <code>clear()</code> method or the <code>flip()</code> method the ''mark'' pointer is discarded. * The <code>clear()</code> method does not ensure zero-ing of the buffer, but does return the ''limit'' pointer to the upper boundary of the underlying array, and the ''position'' pointer to zero. * <code>put()</code> and <code>get()</code> operations for NIO buffers are not thread safe. * You can only <code>map()</code> a {{Javadoc:SE|package=java.nio|java/nio|MappedByteBuffer}} from a {{Javadoc:SE|package=java.nio.channels|java/nio/channels|FileChannel}} up to <code>Integer.MAX_VALUE</code> in size (2GiB); regions beyond this limit can be accessed using an offset greater than zero.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)