THE OCP EXAM TOPICS COVERED IN THIS CHAPTER INCLUDE THE FOLLOWING:
Java File I/O (NIO.2)
In Chapter 8, “IO,” we presented the
java.io API and discussed how to use it to interact with files. In this chapter, we focus on the
java.nio version 2 API, or NIO.2 for short, to interact with files. NIO.2 is an acronym that stands for the second version of the Non-blocking Input/Output API, and it is sometimes referred to as the “New I/O.”
In this chapter, we will show how the NIO.2 API allows us to do a lot more with files and directories than the original
java.io API. We will also show you how to read and modify the attributes of a file. We will conclude the chapter by introducing new NIO.2 methods that were added in Java 8, which rely on streams to perform complex operations with only a single line of code.