Master Java file operations using java.nio.file: Path, Files, Files.walk, Files.lines, BufferedReader/Writer, CSV read/write, directory trees, copy/move/delete, and file attributes.
Background
Java NIO.2 (java.nio.file) replaced the legacy java.io.File API in Java 7. Path is immutable and composable; Files provides static utilities that are cleaner and more powerful than File methods. Files.lines() returns a lazy Stream<String> — perfect for processing large files without loading them entirely into memory.
💡 Files.lines() returns a lazy stream — it reads the file line-by-line as you consume the stream, not all at once. Always wrap it in try-with-resources so the underlying file handle is closed when the stream terminates. For large log files or CSVs (millions of rows), this is the memory-efficient approach.