add files

This commit is contained in:
2026-05-10 16:35:22 +03:30
parent f29dc564fb
commit 42f07c638d
14 changed files with 420 additions and 0 deletions
@@ -0,0 +1,27 @@
package org.FileExamples.WritingFiles;
import java.io.FileWriter;
import java.io.IOException;
public class WriteFileExample01 {
static void main() {
try {
FileWriter fileWriter = new FileWriter("quotes.txt");
fileWriter.write("I'm not superstitious, but I am a little stitious.\n");
fileWriter.write("I am running away from my responsibilities. And it feels good.\n");
fileWriter.close();
} catch (IOException e) {
System.err.println(e.getMessage());
}
try {
FileWriter fileWriter = new FileWriter("quotes.txt", true);
fileWriter.write("I DECLARE BANKRUPTCY!");
fileWriter.close();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}