Java NIO Tutorial
I am starting a Java tutorial series on NIO. This is the first article and will serve as table of contents for the tutorial series. NIO was introduced in Java for buffer oriented and non blocking IO operations. Before that in Java we had only the standard IO based on streams and blocking IO operations.
Difference between Standard IO and NIO
First main difference between the standard IO and NIO is, standard IO is based on streams and NIO is buffer oriented. Buffer oriented operations provide as flexibility in handling data. In buffer oriented NIO, data is first read into a buffer and then it is made available for processing. So we can move back and forth in the buffer. But in the case of streams it is not possible.
Second main difference is, blocking and non-blocking IO operations. In case of streams, a thread will be blocked until it completes the IO operation. Wherein the NIO allows for non-blocking operations. If the data is not available for IO operations, then the thread can do something else and need not stay in blocked mode. With channels and selectors a single thread can manage multiple threads and parallel IO operations.
As part of this Java NIO tutorial series, I will be covering the following topics. If you need any other topics to be covered as part of this tutorials, please add your comment.
- Java NIO Channel
- Java NIO Buffer
- NIO Path
- File Permissions
- File Attributes using Java NIO
- Glob with Java NIO
- Java NIO Files – Delete Copy Move
- Walk File Tree with Java NIO
- Search File Using NIO
- Monitor Folder with Java NIO
- File Read with NIO
- File Write with NIO
- Memory-mapped file with NIO
- Scattering and Gathering with NIO
- File Locking
- Character Sets
- NIO Pipes
- Example: Java TFTP Client with NIO
This Java tutorial was added on 18/05/2015.