NIO buffer types
There are actually various different buffer classes in the java.nio package
which we'll look at on the next few pages:
- ByteBuffer is the most basic and commonly used (and actually exists in a couple
of subclasses we'll see later). It is optimised for writing single bytes or groups of bytes, but
can read and write any Java primitive type.
- For each Java primitive type (short, int, double etc),
there exists a corresponding buffer type: ShortBuffer, IntBuffer, DoubleBuffer etc.
These are optimised for bulk operations on the given primitive type. So for example,
a FloatBuffer can get/put a float array. See:
reading and writing non-byte arrays for more details.
- The CharBuffer has some additional special properties: it can
be accessed as a CharSequence and allows regular expressions
to be run against it.