Java 8 Fundamentals: NIO and NIO2
Java NIO and NIO2 are two evolutions of the Java I/O API. It does not make Java I/O obsolete in any way, but merely bring more functionalities, leveraging the capabilities of file systems, not used by Java I/O.
What you'll learn
Java NIO and NIO2 have been added to the JDK to add more functionalities offered by the file systems that aren't used by Java I/O. In this course, Java 8 Fundamentals: NIO and NIO2, you'll learn how to use Java NIO to read and write data efficiently in bulk mode, and asynchronously to handle more operations simultaneously. First, you'll explore the fundamental objects of this API, including Buffer, Channel, and Selector to precisely set up performant I/O applications for disk or network access. Next, you'll discover how to efficiently navigate through very large directory structures, and how to trigger actions on directory events plugged on the native capabilities of the file systems for better performance. Finally, you'll delve into all of these APIs in action in extended live coding sessions, showing you how to properly use the patterns and how to deal with errors. By the end of this course, you'll have the necessary knowledge to design and create robust and performant I/O systems by following the right patterns, whether you want to access file systems or networks.
Table of contents
- Version Check 0m
- Introducing NIO and NIO2 APIs: What Are You Going to Learn? 3m
- What Do You Need to Know to Follow This Course? 1m
- Agenda and Organization of This Course 1m
- Agenda and Organization of This Module 1m
- Introducing the Java NIO API: Why It's Been Added to the JDK? 3m
- Understanding What NIO Provides That Is Missing in Java I/O 2m
- Introducing Buffers, Channels, and Selectors 3m
- Understanding Channels and In-memory File Channels 3m
- Understanding Buffers and Their Main Properties 4m
- Writing Content to a File Using Buffers and Channels 3m
- Reading Content from a File Using the Flip Operation 4m
- Understanding the Pattern to Read the Content of a File 1m
- Understanding Scattering Read and Gathering Write Operations 3m
- Using Mapped Byte Buffers to Map Large Files in Memory 3m
- Introducing ByteBuffer to CharBuffer Conversion Using Charsets 2m
- Understanding the Patterns to Convert Bytes Using Charsets 2m
- Convert NIO Objects to I/O Objects Using the Channels Factory 1m
- Live Coding: Simple Writing and Reading in a ByteBuffer 4m
- Live Coding: Flipping a ByteBuffer and Writing It to a File 3m
- Live Coding: Reading Back Data from the FileChannel 3m
- Live Coding: Writing Latin-1 or UTF-8 Text to a File 5m
- Live Coding: Reading Latin-1 or UTF-8 Test from a File 2m
- Module Wrap-up 1m
- Agenda: Understanding Asynchronous Operations Using Selectors 1m
- What Does It Mean for an Operation to Be Asynchronous? 4m
- Understanding Selectors to Set up Asynchronous Systems in NIO 3m
- Pattern to Set up a Selector to Read from a Socket Channel 3m
- Setting up the Selector to Accept an Incoming Connection 2m
- Read the Content Sent Through the Socket Using the Selector 2m
- Live Coding: Setting up the Asynchronous Server Socket Channel 2m
- Live Coding: Accepting an Incoming Connection Request 5m
- Live Coding: Reading the Text Content Incoming from the Socket 3m
- Live Coding: Writing a Basic Client to Send Data to the Server 4m
- Module Wrap-up 1m
- Agenda: Using the Use of File Systems in Java NIO2 1m
- Introducing the File Systems Support in Java NIO2 2m
- Understanding the API and File System Providers 1m
- Modeling File Systems 1m
- Understanding File Store 1m
- Getting File Systems and Stores from the FileSystemProvider 3m
- Creating I/O and NIO Objects with the FileSystem Object 2m
- Creating Directories Using FileSystem or FileSystemProvider 1m
- Pattern to Create Directories from Files, Paths, and Names 4m
- Understanding Path Creation and Binding to File Systems 1m
- Accessing Files Attributes Using the FileSystemProvider 3m
- Introducing the Jar File System to Handle JAR and ZIP Files 1m
- Creating a ZIP or JAR Archive File 1m
- Copying Files and Creating Directories in a ZIP Archive File 2m
- Using OutputStreams or ByteChannels to Write to an Archive File 2m
- Live Coding: Pattern to Read Available File Systems 3m
- Live Coding: Understanding Path Creation from FileSystems 3m
- Live Coding: Getting Root Directories and File Stores 3m
- Live Coding: Creating a ZIP Archive File Using the FileSystem API 3m
- Live Coding: Copying Existing Files in a ZIP Archive File 3m
- Live Coding: Creating Content in a ZIP Archive File 3m
- Module Wrap-up 1m
- Agenda: Visiting Directory Trees with NIO2 1m
- Writing a Directory Filtering Pattern Using Regular Expression 3m
- Using a Directory Stream to Analyze the Content of a Directory 1m
- Exporing the Content of a Directory in a Depth-first Approach 3m
- Using the Files.walk Pattern to Explore Directory Trees 2m
- Looking for Content in a Directory Tree Using Files.find 1m
- Understanding Weak Consitency When Exporing Directories 1m
- Introducing the Walking Tree Pattern and File Visitors 2m
- Setting up a FileVisitor to Walk a Directory Tree 3m
- Using the Walking Directory Tree Pattern to Write a File Finder 1m
- Live Coding: Counting Filtered Files from a Directory 6m
- Live Coding: Counting Directories Using a FileVisitor on a Tree 5m
- Live Coding: Couting File Types Using a FileVisitor on a Tree 4m
- Module Wrap-up 1m
- Agenda: Listening to File Creation Deletion and Modification 1m
- Understanding Legacy Solutions to Catch File Creations 4m
- Setting up a Watch Service Pattern to Listen to Events 2m
- Understanding the Watch Key Object 2m
- Processing Available Events from the WatchKey 1m
- Live Coding: Setting up a Watch Service 5m
- Live Coding: Testing the Watch Service 3m
- Module and Course Wrap-up 2m