Commit 318f6fed authored by 9831111's avatar 9831111 🙂

Add writeToFile method.

parent e79617ac
...@@ -4,6 +4,8 @@ import javax.swing.border.TitledBorder; ...@@ -4,6 +4,8 @@ import javax.swing.border.TitledBorder;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
public class CreateNewGameFrame extends JFrame { public class CreateNewGameFrame extends JFrame {
private JPanel settingPanel; private JPanel settingPanel;
...@@ -123,6 +125,15 @@ public class CreateNewGameFrame extends JFrame { ...@@ -123,6 +125,15 @@ public class CreateNewGameFrame extends JFrame {
new OnlineModeFrame(); new OnlineModeFrame();
} }
} }
public void writeToFile(String dataToWrite) {
File file = new File("Games.txt");
try (FileWriter fileWriter = new FileWriter(file, true)) {
fileWriter.write(dataToWrite + "\n");
} catch (Exception ex) {
System.out.println("No game found ! ");
ex.printStackTrace();
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment