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
- java.io — Java's original input and output package: byte streams, character readers and writers, and object serialization.
Taught in
- Serialization: What Survives The Trip — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Paths And Files With NIO.2 — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep