O'Reilly logo

OCP Oracle® Certified Professional Java® SE 8 Programmer II by Scott Selikoff, Jeanne Boyarsky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9 NIO.2

THE OCP EXAM TOPICS COVERED IN THIS CHAPTER INCLUDE THE FOLLOWING:

  • ✓  Java File I/O (NIO.2)
    • Use Path interface to operate on file and directory paths
    • Use Files class to check, read, delete, copy, move, manage metadata of a file or directory
    • Use Stream API with NIO.2

images

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required