~/ learn/ java-from-zero/ cards/ NIO.2: Path & Files
1 of 4

Type a Path.of and Files.readString call

Type a Path.of and Files.readString call

Answer

Path p = Path.of("config.txt"); String s = Files.readString(p, StandardCharsets.UTF_8);

readString (Java 11+) reads the entire file in one call. Path.of is the modern replacement for new File() — it does not touch the file system, it just builds a path object.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/bf4a596f-f0da-4a21-bcba-f2e1f61f1721/flashcard utf-8 LF