Java Streams   «Prev  Next»

Lesson 3Java Streams Course Requirements
Objective Explore how to get the most from this course.

Java Streams Course Requirements

Everything you need to complete this course is available online.

Java Streams Software

In order to complete the exercises and course project, you need any Java compiler and VM that supports JDK 7 or higher and a browser that supports JavaScript. Note the following difference between NIO and NIO 2.
  1. java.io.File class exists since Java 1.0
  2. java.nio.file.Files class exists since 1.7
There is a big difference between the two classes and mentioning the Java version for these APIs (when they were originally published ) is useful for your understanding.

Question: What is the difference between java.io.File class in Java 1.0 and java.nio.file.Files in Java 7?
The java.io.File class and java.nio.file.Files class, part of the original I/O API and the newer NIO.2 API respectively, provide capabilities for file manipulation in Java. While both classes serve a similar purpose, their features, flexibility, and the methodologies they employ are substantially different. This difference is primarily due to advancements in technology and the evolving requirements of modern applications, leading to an upgrade from the older I/O API to the newer, more efficient NIO.2 API.

java.io.File (Java 1.0)

The java.io.File class, introduced in Java 1.0, provides an abstraction for file and directory pathnames. It allows you to perform basic operations like creating new files or directories, renaming or deleting files, and querying file or directory properties.
However, it has several limitations:
  1. It can't handle symbolic links. If a symbolic link is encountered, it deals with the link itself and not the target of the link.
  2. The rename() method behaves inconsistently across different platforms.
  3. It doesn't provide any methods to handle file metadata or permissions.
  4. It doesn't support scalable bulk operations on directories.
  5. It lacks support for advanced features like asynchronous I/O operations.


java.nio.file.Files (Java 7)

The java.nio.file.Files class, introduced in Java 7 with the NIO.2 API, is more feature-rich and flexible than java.io.File. It includes several advanced features addressing the limitations of the old I/O API:
  1. It provides support for symbolic links. You can choose to follow symbolic links or to operate on the link itself.
  2. It includes methods to handle file metadata and permissions, which are absent in java.io.File.
  3. It provides methods for scalable bulk operations on directories, which can be particularly useful when dealing with large file systems.
  4. It offers methods for file copy, move, and deletion with finer-grained control and options.
  5. It includes advanced features like mapping a file directly into memory for faster processing, support for file change notifications, and asynchronous file operations.

The transition from java.io.File to java.nio.file.Files signifies a major enhancement in Java's ability to manipulate files and directories, addressing several critical limitations and inconsistencies in the original I/O API. While java.io.File is sufficient for simple file manipulation tasks, for more advanced or large-scale operations, the java.nio.file.Files class from the NIO.2 API provides a more powerful and flexible option.


Course Download Files

The source code for the exercise and course project answers is included in a compressed download file for your convenience. The download file is available in Windows, Macintosh, and Unix compressed formats.

Javadeploy Store

While no book is required for this course, there are several that can offer additional information and serve as helpful resources. Although Java streams is an important topic, it is not a very sexy one. There aren't many resources that cover it, though a number of books devote a chapter or two to it.
For more advanced file manipulation in Java I recommend

Modern Java