Java NIO Tutorial for Beginners
In this section we are giving you Java NIO Tutorials for beginners which is discussing java.nio package from start.
In this section we are giving you Java NIO Tutorials for beginners which is discussing java.nio package from start.
Java NIO Tutorial for Beginners - Learn java.nio package from beginning
Java NIO package was first introduced in JDK 1.4 and since then there is many
new changes. In Java 8 NIO.2 was added with many new features and improvements.
In this section we are exploring Java NIO package in detail which will help
beginners in learning this package from beginning.
If you are new to Java NIO package then you will find complete tutorials and
many examples. You will learn this package from start, first we will explain all
the classes and interfaces that come with the package and then teach you to use
these in programming.
What is Java NIO package?
The NIO stands for New IO, which is essentially a set of new IO API in Java
with improvements and enhanced features as compared to previous IO (java.io)
packages of Java. Java NIO package was first introduced in JDK (Java) 1.4. Java
NIO package comes with API which provides a different way of working with IO
then standard IO API's.
Java NIO and IO packages provides following features in the Java API:
- The IO API's are used to perform input and output operations
using data streams, serialization and the file system.
- It also provides the support for Charsets, decoders, and
encoders, for translating between bytes and Unicode characters.
These are very important as its always necessary to correctly
encode and decode the data while reading/writing.
- It provides the API's to access the file, read file
attributes and file systems details.
- It comes with the robust set of APIs for building scalable
servers. In case of server you can use asynchronous or
multiplexed, non-blocking I/O operations to meet your
application needs and IO API supports all these.
What is difference between IO and NIO packages?
Most of the programmers are already aware about the Java IO package which
provides all the functionality that NIP package provides. Then what is the need
of another IO package? What benefits NIO package provides over IO package?
The main difference between traditional IO and (new) NIO is that IO is
blocking, while NIO is non-blocking.
Blocking I/O: Blocking IO (in case of java.io packages)
actually wait for the data to be write or read before returning when the IO
operation is requested from the Java program
Non blocking I/O: The Non blocking IO operation does not
wait for the data to be read or write before returning when such operation is
requested from calling Java program
Java NIO Tutorial for Beginners
Here are the tutorials of Java java.nio package for beginners:
- Create a int array with the help of int buffer.
- Use of hasArray() method of ByteBuffer class in java.
- Writes the given character into buffer at the given index.
- How to get specific index value from short buffer.
- Creates a view of byte buffer as a char buffer.
- Check for number of elements exists between the current position and the limit of a double type buffer.
- Get the capacity of a double type buffer
- Compare a int buffer with another int buffer.
- Use of equals() method of FloatBuffer class in java.
- How to rewind the int buffer in java.
- ShortBuffer in java, How to reset the mark of short buffer.
- Create a int buffer by wrapping an int array into a buffer.
- Use of equals() method of LongBuffer class in java.
- ShortBuffer in java, Transfer the content of a short buffer into another.
- How to check long buffer is direct or not in java.
- How to get given index value from FloatBuffer in java.
- Creates a view of byte buffer as a float buffer.
- Use of equals() method of IntBuffer class in java.
- Get the capacity of a buffer
- How to write the given byte into byte buffer.
- Transfer the content of a float array into float buffer.
- How to rewind float buffer in java.
- ShortBuffer in java, Compare a short buffer with another short buffer.
- Java MappedByteBuffer example, How to create mapped byte buffer in java.
- Use of isDirect() method of intBuffer class in java.
- ShortBuffer in java, Use of toString() method of ShortBuffer class.
- Java nio package - Learn how to use java nio package.
- Order bytes from most significant to least significant.
- Calculate total number of elements remaining in the buffer.
- Transfer the content of a float buffer into another float buffer.
- Create a short array with the help of short buffer.
- How to get specific index value from int buffer.
- How to transfer the content of a long buffer into another long buffer.
- Creates a read-only float buffer that shares the content of float buffer.
- Compare two buffer's content
- Compare a double type buffer to another object
- Write a float value into float buffer at given index.
- ShortBuffer in java, How to rewind a short buffer in java.
- How to transfer the value of a long array into long buffer.
- Use of equals() method of ByteBuffer class in java.
- How to allocate a new long buffer in java.
- Compare buffer to another object.
- How to get specific index value from long buffer.
- Use of getFloat() method of ByteBuffer class in java.
- How to allocate a float buffer in java.
- ShortBuffer in java, Clean a short buffer by using clear method.
- Use of slice method of FloatBuffer class in java.
- Write a byte into byte buffer at given index.
- Use of hasCode method of FloatBuffer class in java.
- ShortBuffer in java, Use of isDirect() method of ShortBuffer class in java.
- Write a long value at given index into long buffer.
- ShortBuffer in java, Use of slice method of ShortBuffer class.
- How to read all value from int buffer in java.
- How to create a read-only long buffer in java.
- Creates a duplicate int buffer that shares the content of int buffer.
- Check for any elements exists between the current position and the limit of a double type buffer.
- ShortBuffer in java, How to transfer content from short buffer to short array.
- Use of getChar method of ByteBuffer Class in java.
- Place array of bytes in buffer
- Place array of double in a buffer
- How to create a long buffer with the help of byte buffer.
- Use of rewind() method of FloatBuffer class.
- Reads the character at buffer's current position.
- Get the limit position and capacity of a double type buffer.
- Check long buffer is read_only or not.
- Transfer the content of a int array into int buffer.
- Java MappedByteBuffer example, How to create a large size file in java.
- Use of rewind method in java.
- Use of hasRemaining() method in float buffer class.
- Use of putChar() method of ByteBuffer class.
- How to transfer data from ByteBuffer to byte array in java.
- How to create a int buffer with the help of byte buffer.
- ShortBuffer in java, Define the order of byte in short buffer.
- Order bytes from least significant to most significant.
- Check for number of elements exists between the current position and the limit of a buffer.
- Creates a view of byte buffer as a int buffer.
- Get the limit position and capacity of a character buffer.
- Creates a view of this byte buffer as a double buffer.
- Use of hashCode() method of LongBuffer class in java.
- How to create a duplicate buffer of a long buffer in java.
- ShortBuffer in java, Use of hashCode() in short buffer.
- ShortBuffer in java, Use of remaining() method in short buffer.
- Create a long buffer by wrapping an long array.
- Create a short buffer by using wrap method of ShortBuffer class.
- How to Create a ByteBuffer using Byte Array in java.
- How to get the capacity of ByteBuffer in java.
- Create a duplicate short buffer that shares the content of a short buffer.
- How to create a short buffer with the help of byte buffer.
- Creates a read-only int buffer that shares the content of int buffer.
- ShortBuffer in java, Write a short value into short buffer at given index.
- Use of getInt() method of ByteBuffer class in java.
- How to clear a float buffer in java.
- How to compute limit of ByteBuffer in java.
- Use of isDirect() method of byte buffer class in java.
- Creates a duplicate float buffer that shares the content of float buffer.
- ShortBuffer in java, Transfer the array's elements into short buffer.
- Transfer the content of a int buffer into another int buffer.
- Compare a long buffer with another long buffer.
- ShortBuffer in java, Create a read-only short buffer that shares the content of short buffer.
- Wraps a character sequence into a buffer.
- How to clean a buffer using clear method in java.
- Creates a view of byte buffer as a long buffer.
- Wraps a character array into a buffer
- How to create a long array with the help of long buffer.
- Writes the given double value into a buffer at the given index.
- Use of array() method of FloatBuffer class in java.
- Write a int value into int buffer at given index.
- ShortBuffer in java, Use of hasRemaining() method in short buffer.
- Create a float buffer by using wrap method of FloatBuffer class.
- Wraps a double type array into a buffer
- How to get bytes from ByteBuffer in java.
- Compare a float buffer with another float buffer.
- Use of isReadOnly() method in java.
- Compare two double type buffer's content
- Transfer the content of a float buffer into float array.
- How to allocate a short buffer in java.
- How to transfer value from long buffer to long array.
- How to clear int buffer in java.
- ShortBuffer in java, Use of equals() method of ShortBuffer class in java.
- Use of toString() method of FloatBuffer class.
- How to transfer data from int buffer to int array.
- How to get specific index value from ByteBuffer in java.
- Use of putDouble() and getDouble() method of ByteBuffer class.
- How to allocate a new int buffer in java.