You are previewing Pro Java 7 NIO.2.
O'Reilly logo
Pro Java 7 NIO.2

Book Description

Pro Java 7 NIO.2 addresses the three primary elements that offer new input/output (I/O) APIs in Java 7, giving you the skills to write robust, scalable Java applications:

An extensive file I/O API system addresses feature requests that developers have sought since the inception of the JDK

A socket channel API addresses multicasting, socket binding associated with channels, and related issues

An asynchronous I/O API enables mapping to I/O facilities, completion ports, and various I/O event port mechanisms to enhance scalability

NIO.2 for the Java platform, known as JSR 203, is a major feature of the new Java JDK 7 under the leadership of Alan Bateman as an OpenJDK project. Take advantage of these exciting new developments with Pro Java 7 NIO.2.

What you'll learn

How to carry out Path class operations

How to get/set file metadata through the java.nio file attribute API (including POSIX)

How to manage symbolic and hard links (including create, delete, and find target)

How to deal with files and directories through the new java.nio.file.Files API

How to use the FileVisitor API to develop file recursive operations

How to explore the Watch Service API and file change notification

How to use the new SeekableByteChannel API for Random Access File

How to develop blocking/non-blocking socket-based applications

How to explore the jewel of NIO.2: the Asynchronous Channel API

How to use the Zip File System Provider and write a custom file system provider

How to refactor java.io.File code

Who this book is for

This book is for experienced Java programmers new to Java 7 and those with some experience with Java 7.

Table of Contents

  1. Title
  2. Contents at a Glance
  3. Contents
  4. About the Author
  5. About the Technical Reviewer
  6. Acknowledgments
  7. Preface
    1. Who This Book Is For
    2. What This Book Covers
  8. CHAPTER 1: Working with the Path Class
    1. Introducing the Path Class
    2. Defining a Path
    3. Getting Information About a Path
    4. Converting a Path
    5. Combining Two Paths
    6. Constructing a Path Between Two Locations
    7. Comparing Two Paths
    8. Iterate over the Name Elements of a Path
    9. Summary
  9. CHAPTER 2: Metadata File Attributes
    1. Supported Views in NIO.2
    2. Determining Views Supported by a Particular File System
    3. Basic View
    4. DOS View
    5. File Owner View
    6. POSIX View
    7. ACL View
    8. File Store Attributes
    9. User-Defined File Attributes View
    10. Summary
  10. CHAPTER 3: Manage Symbolic and Hard Links
    1. Introducing Links
    2. Creating Links from the Command Line
    3. Creating a Symbolic Link
    4. Creating a Hard Link
    5. Checking a Symbolic Link
    6. Locating the Target of a Link
    7. Checking If a Link and a Target Point to the Same File
    8. Summary
  11. CHAPTER 4: Files and Directories
    1. Checking Methods for Files and Directories
    2. Creating and Reading Directories
    3. Creating, Reading, and Writing Files
    4. Creating Temporary Directories and Files
    5. Summary
  12. CHAPTER 5: Recursive Operations: Walks
    1. The FileVisitor Interface
    2. The SimpleFileVisitor Class
    3. Starting the Recursive Process
    4. Common Walks
    5. Summary
  13. CHAPTER 6: Watch Service API
    1. The Watch Service API Classes
    2. Implementing a Watch Service
    3. Other Examples of Using a Watch Service
    4. Summary
  14. CHAPTER 7: Random Access Files
    1. Brief Overview of ByteBuffer
    2. Brief Overview of Channels
    3. Using the SeekableByteChannel Interface for Random Access to Files
    4. Working with FileChannel
    5. Summary
  15. CHAPTER 8: The Sockets APIs
    1. NetworkChannel Overview
    2. Writing TCP Server/Client Applications
    3. Writing UDP Server/Client Applications
    4. Summary
  16. CHAPTER 9: The Asynchronous Channel API
    1. Synchronous I/O vs. Asynchronous I/O
    2. Asynchronous I/O Big Picture
    3. Developing Asynchronous Applications
    4. Summary
  17. CHAPTER 10: Important Things to Remember
    1. Refactoring java.io.File Code
    2. Working with the ZIP File System Provider
    3. Considerations on Developing a Custom File System Provider
    4. Useful Methods
    5. Summary
  18. Index