Created
April 12, 2019 15:16
-
-
Save bauepete/f345b43762c111525cbcb06e5174fc0c to your computer and use it in GitHub Desktop.
Files.write usage.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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