~/ 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/e2581eb0-6bac-4452-bc1c-018638c166da/flashcard utf-8 LF