java.nio.file · java.base · since Java 1.7

Files

declaration
public final class Files

Every file operation as a static method: read/write whole files, copy/move with options, walk trees, create/delete, query metadata. The workhorse of java.nio.file.

Key methods

static String readString(Path) / static Path writeString(Path, CharSequence)Whole-file text I/O (UTF-8 default).
static List<String> readAllLines(Path) / Stream<String> lines(Path)Eager / lazy line access (close the stream!).
static Path copy(Path, Path, CopyOption...) / move(...)REPLACE_EXISTING, ATOMIC_MOVE options.
static Stream<Path> walk(Path) / list(Path)Recursive / single-level listing — resource-holding streams.
static boolean exists(Path) / isRegularFile / isDirectoryProbes.
static Path createDirectories(Path)mkdir -p.
static BufferedReader newBufferedReader(Path, Charset)Reader with explicit encoding.