temporary file creation functionality

This commit is contained in:
Marcin Hutek 2023-12-08 17:36:17 +01:00
parent c09edc1103
commit e42f0ac225

View File

@ -0,0 +1,28 @@
package model;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class TemporaryFile {
public static final String FILE_NAME = "temporary_file.txt";
public void createEmptyFile() {
try {
FileWriter fileWriter = new FileWriter(FILE_NAME);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void addToFile(String fileInput) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(FILE_NAME, true));
writer.write(fileInput + "\n");
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}