Nio:new IO
Starting with JDK1.4, the new IO, which can map a disk file into memory, we then read the data in memory.
stored in the Java.nio package
Java NIO (new IO) is a new IO API introduced by the Java1.4 version, which can replace the standard Java IO API, which is now primarily used in servers, and is sufficient for us to write code that still uses traditional IO.
Java NiO provides a different way of working with iOS than standard IO:
Channels and buffers (channels and buffers): Standard IO is based on byte stream and character stream, and NiO is based on channel (channels) and buffers (buffer), and the data is always read from the channel into the buffer. or write from the buffer to the channel.
Asynchronous (Asynchronous IO): Java NIO allows you to use IO asynchronously, for example: When a thread reads data from a channel to a buffer, the thread can do something else. When the data is written to the buffer, the thread can continue to process it. Writing a channel from a buffer is similar.
Selectors (selector): Java NiO introduces the selector concept, which is used to listen for events on multiple channels (e.g., link open, data arrival). Therefore, a single thread can listen to multiple data channels.
Java Core Class Library-io-nio overview