Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Files.write usage.
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
public class FileWriter {
public static void main(String[] args) throws IOException {
System.out.println("File Write Collection");
String[] fileContent = {
"The first line",
"Hold the second line",
"A final line"
};
Files.write(Paths.get("textfile.txt"), Arrays.asList(fileContent), StandardCharsets.UTF_8);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment