Answers for "how to save a string to a text file"

0

how to save a string to a text file

Path path = Paths.get("output.txt");
String contents = "Hello";

try {
    Files.writeString(path, contents, StandardCharsets.UTF_8);
} catch (IOException ex) {
	// Handle exception
}
Posted by: Guest on February-07-2022

Code answers related to "how to save a string to a text file"

Browse Popular Code Answers by Language