Skip to content

Instantly share code, notes, and snippets.

@bauepete
Created April 12, 2019 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bauepete/f345b43762c111525cbcb06e5174fc0c to your computer and use it in GitHub Desktop.
Save bauepete/f345b43762c111525cbcb06e5174fc0c to your computer and use it in GitHub Desktop.
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