Java NIO Tutorial for Beginners

Ads
 

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:

  1. Create a int array with the help of int buffer.
  2. Use of hasArray() method of ByteBuffer class in java.
  3. Writes the given character into buffer at the given index.
  4. How to get specific index value from short buffer.
  5. Creates a view of byte buffer as a char buffer.
  6. Check for number of elements exists between the current position and the limit of a double type buffer.
  7. Get the capacity of a double type buffer
  8. Compare a int buffer with another int buffer.
  9. Use of equals() method of  FloatBuffer class in java.
  10. How to rewind the int buffer in java.
  11. ShortBuffer in java, How to reset the mark of short buffer.
  12. Create a int buffer by wrapping an int array into a buffer.
  13. Use of equals() method of LongBuffer class in java.
  14. ShortBuffer in java, Transfer the content of a short buffer into another.
  15. How to check long buffer is direct or not in java.
  16. How to get given index value from FloatBuffer in java.
  17. Creates a view of  byte buffer as a float buffer.
  18. Use of equals() method of IntBuffer class in java.
  19. Get the capacity of a buffer
  20. How to write the given byte into byte buffer.
  21. Transfer the content of a float array into float buffer.
  22. How to rewind float buffer in java.
  23. ShortBuffer in java, Compare a short buffer with another short buffer.
  24. Java MappedByteBuffer example, How to create mapped byte buffer in java.
  25. Use of isDirect() method of intBuffer class in java.
  26. ShortBuffer in java, Use of toString() method of ShortBuffer class.
  27. Java nio package - Learn how to use java nio package.
  28. Order bytes from most significant to least significant.
  29. Calculate total number of elements remaining in the buffer.
  30. Transfer the content of a float buffer into another float buffer.
  31. Create a short array with the help of short buffer.
  32. How to get specific index value from int buffer.
  33. How to transfer the content of a long buffer into another long buffer.
  34. Creates a read-only float buffer that shares the content of float buffer.
  35. Compare two buffer's content
  36. Compare a double type buffer to another object
  37. Write a float value into float buffer at given index.
  38. ShortBuffer in java, How to rewind a short buffer in java.
  39. How to transfer the value of a long  array into long buffer.
  40. Use of equals() method of ByteBuffer class in java.
  41. How to allocate a new long buffer in java.
  42. Compare buffer to another object.
  43. How to get specific index value from long buffer.
  44. Use of getFloat() method of ByteBuffer class in java.
  45. How to allocate a float buffer in java.
  46. ShortBuffer in java, Clean a short buffer by using clear method.
  47. Use of slice method of FloatBuffer class in java.
  48. Write a byte into byte buffer at given index.
  49. Use of hasCode method of FloatBuffer class in java.
  50. ShortBuffer in java, Use of isDirect() method of ShortBuffer class in java.
  51. Write a long value at given index into long buffer.
  52. ShortBuffer in java, Use of slice method of ShortBuffer class.
  53. How to read all value from int buffer in java.
  54. How to create a read-only long buffer in java.
  55. Creates a duplicate int buffer that shares the content of int buffer.
  56. Check for any elements exists between the current position and the limit of a double type buffer.
  57. ShortBuffer in java, How to transfer content from short buffer to short array.
  58. Use of getChar method of ByteBuffer Class in java.
  59. Place array of bytes in buffer
  60. Place array of double in a buffer
  61. How to create a long buffer with the help of byte buffer.
  62. Use of rewind() method of FloatBuffer class.
  63. Reads the character at buffer's current position.
  64. Get the limit position and capacity of a double type buffer.
  65. Check long buffer is read_only or not.
  66. Transfer the content of a int array into int buffer.
  67. Java MappedByteBuffer example, How to create a large size file in java.
  68. Use of rewind method in java.
  69. Use of hasRemaining() method in float buffer class.
  70. Use of putChar() method of ByteBuffer class.
  71. How to transfer data from ByteBuffer to byte array in java.
  72. How to create a int buffer with the help of byte buffer.
  73. ShortBuffer in java, Define the order of byte in short buffer.
  74. Order bytes from least significant to most significant.
  75. Check for number of elements exists between the current position and the limit of a buffer.
  76. Creates a view of  byte buffer as a int buffer.
  77. Get the limit position and capacity of a character buffer.
  78. Creates a view of this byte buffer as a double buffer.
  79. Use of hashCode() method of LongBuffer class in java.
  80. How to create a duplicate buffer of a long buffer in java.
  81. ShortBuffer in java, Use of hashCode() in short buffer.
  82. ShortBuffer in java, Use of remaining() method in short buffer.
  83. Create a long buffer by wrapping an long array.
  84. Create a short buffer by using wrap method of ShortBuffer class.
  85. How to Create a ByteBuffer using Byte Array in java.
  86. How to get the capacity of ByteBuffer in java.
  87. Create a duplicate short buffer that shares the content of a short buffer.
  88. How to create a short buffer with the help of byte buffer.
  89. Creates a read-only int buffer that shares the content of int buffer.
  90. ShortBuffer in java, Write a short value into short buffer at given index.
  91. Use of getInt() method of ByteBuffer class in java.
  92. How to clear a float buffer in java.
  93. How to compute limit of ByteBuffer in java.
  94. Use of isDirect() method of byte buffer class in java.
  95. Creates a duplicate float buffer that shares the content of float buffer.
  96.  ShortBuffer in java, Transfer the array's elements into short buffer.
  97. Transfer the content of a int buffer into another int buffer.
  98. Compare a long buffer with another long buffer.
  99. ShortBuffer in java, Create a read-only short buffer that shares the content of short buffer.
  100. Wraps a character sequence into a buffer.
  101. How to clean a buffer using clear method in java.
  102. Creates a view of  byte buffer as a long buffer.
  103. Wraps a character array into a buffer
  104. How to create a long array with the help of long buffer.
  105. Writes the given double value into a buffer at the given index.
  106. Use of array() method of FloatBuffer class in java.
  107. Write a int value into int buffer at given index.
  108. ShortBuffer in java, Use of hasRemaining() method in short buffer.
  109. Create a float buffer by using wrap method of FloatBuffer class.
  110. Wraps a double type array into a buffer
  111. How to get bytes from ByteBuffer in java.
  112. Compare a float buffer with another float buffer.
  113. Use of isReadOnly() method in java.
  114. Compare two double type buffer's content
  115. Transfer the content of a float buffer into float array.
  116. How to allocate a short buffer in java.
  117. How to transfer value from long buffer to long array.
  118. How to clear int buffer in java.
  119. ShortBuffer in java, Use of equals() method of ShortBuffer class in java.
  120. Use of toString() method of FloatBuffer class.
  121. How to transfer data from int buffer to int array.
  122. How to get specific index value from ByteBuffer in java.
  123. Use of putDouble() and getDouble() method of ByteBuffer class.
  124. How to allocate a new int buffer in java.

Ads

Ads