import java.io.*;
import java.nio.charset.*;
import java.nio.file.*;
Path file = Path.of("note.txt");
// *** before: ***
Files.write(file, "hello".getBytes(StandardCharsets.UTF_8));
String text1 = new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
// *** in version 11: ***
Files.writeString(file, "hello"); // UTF-8 by default
String text2 = Files.readString(file);
System.out.println(text1 + " " + text2);