My take:
Short version
This is the addition of the java.nio.file package with its significantly enhanced file and file system functionality.
In terms of network sockets or low-level file access, NIO == NIO.2 with some usability improvements.
Longer version
Java IO
Package: java.io
Old Blocking I / O API
Java NIO
Java 1.4 adds a new non-blocking API.
Package: java.nio
Java non-blocking I / O. Classes such as Selector , SelectorKey , Channel .
It seems to me that NIO was a big step forward for network I / O ( Selector , SelectorKey , SocketChannel , ServerSocketChannel , Buffer ), much less for file I / O ( FileChannel and Buffer only, including memory-mapped files). This is a fairly low-level API for both the network and file parts.
Java NIO.2
Added in Java 7. This is mainly the addition of a significantly improved API for file and file system management and addressing. The new file and file system API is at a relatively high level.
Package: java.nio.file and a few additions to the parent java.nio .
This is an add-on for file I / O and just a few minor additions to network I / O or a low-level file API.
The most notable low-level, optional file-related API add-ons are AsynchronousSocketChannel , AsynchronousServerSocketChannel and AsynchronousFileChannel , which add callback options for some methods. Asynchronous versions are mostly convenient; such display interfaces might have been hacked together even earlier, but they are now available in the JRE.
The new file API provides many useful functions - much more useful file system addressing with Path, significantly improved ZIP file processing using a custom file system provider, access to special file attributes, many convenient methods, such as reading the entire file with one command, copying the file using one command, etc. But all this is connected with the file / file system and everything is of a rather high level.
Repeating what I said above in terms of network sockets or low-level file access, NIO == NIO.2
Relevant Links
Espinosa Sep 03 '19 at 19:51 2019-09-03 19:51
source share