NIO.2

The java.nio.file API, added in Java 7, built around the Path interface and the Files utility class.

In more detail

Path describes a location and can be normalized, resolved and relativized without touching the disk. Files performs the input and output: creating, reading, writing, copying, moving, deleting and walking. Files.list, Files.walk and Files.lines return lazy streams that should be closed.

Example

Path p = Path.of("logs", "a.txt");
List<String> lines = Files.readAllLines(p);

Related terms

Taught in

References

Certification courses