In Java, the New I/O (NIO) API, introduced in Java 1.4, provides a more flexible and efficient way to perform input and output operations compared to the traditional I/O (java.io) API. The NIO API is part of the java.nio package and is particularly useful for building high-performance network applications and file handling tasks.
Related Tags
Tutorials
Java IO is a collection of APIs targeted at reading and writing data from various sources to several targets. For example, we can read data from a file or over a network, write to a file or write a response back over the network. This page categorizes the various IO-related common tasks into a logical grouping so …
When using FileChannel transferTo() and transferFrom() methods, data doesn’t pass through the Java heap, thus reducing garbage collection pressure.
Learn about Java memory-mapped files and learn to read and write content from a memory mapped file with the help of RandomAccessFile and MemoryMappedBuffer. 1. Java Memory-mapped IO If you know how java IO works at lower level, then you will be aware of buffer handling, memory paging and other …
Java NIO Channels provide an important new capability known as scatter/gather (referred to in some circles as vectored I/O). Scatter/gather is a simple yet powerful concept. Scatter/gather is a technique through which bytes can be read from a stream into a set of buffers (vectors) with a single read() invocation …
Channels are the second major addition to java.nio after buffers which we have learned in my previous tutorial in detail. Channels provide direct connection to the I/O services. A Channel is a medium that transports data efficiently between byte buffers and the entity on the other end of the channel …
Java Buffer classes are the foundation upon which java.nio is built. In this tutorial, we will take a closer look at the buffers. We will discover the various buffer types, and learn how to use them. We’ll then see how the java.nio buffers relate to the Channel classes of java.nio.channels. …
Java New input/output (NIO) was introduced with JDK 1.4. Picking up where Standard IO leaves, NIO provides high-speed, block-oriented IO to Java library. By defining classes to hold data, and by processing that data in blocks, NIO takes advantage of low-level optimizations in a way that the java.io package could …
The Path class, introduced in the Java SE 7 release, is one of the primary entry points of the java.nio.file package. If our application uses Java New IO, we should learn more about the powerful features available in this class. In this Java tutorial, we are learning 6 ways to …
Learn to read small and large files from the filesystem using the Java NIO APIs Path, FileChannel, ByteBuffer and MappedByteBuffer.