| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + import java.io.FileWriter; | ||
| 2 | + import java.io.IOException; | ||
| 3 | + | ||
| 4 | + | ||
| 5 | + public class WriteToTextFile { | ||
| 6 | + | ||
| 7 | + public static void main(String[] args) { | ||
| 8 | + try { | ||
| 9 | + FileWriter writer = new FileWriter("myfile.txt", true); | ||
| 10 | + writer.write("Writing to a text file in Java"); | ||
| 11 | + writer.write("\r\n"); // write new line | ||
| 12 | + writer.write("See you! Bye"); | ||
| 13 | + writer.close(); | ||
| 14 | + } catch (IOException e) { | ||
| 15 | + e.printStackTrace(); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments