Fxml #8
|
@ -15,7 +15,7 @@ public class App {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(new App().getGreeting());
|
System.out.println(new App().getGreeting());
|
||||||
|
|
||||||
FileIO io = new FileIO();
|
FileIO io = new FileIO(System.getProperty("user.dir") + File.separator + "tournierverwaltung_angrynerds");
|
||||||
Tournament tournament= new Tournamenttest("helloo");
|
Tournament tournament= new Tournamenttest("helloo");
|
||||||
io.saveTournament(tournament);
|
io.saveTournament(tournament);
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
package ch.zhaw.projekt2.turnierverwaltung;
|
package ch.zhaw.projekt2.turnierverwaltung;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.ArrayList;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class FileIO {
|
public class FileIO {
|
||||||
File saveDir;
|
private File mainDir;
|
||||||
File saves;
|
private File saves;
|
||||||
|
|
||||||
|
|
||||||
public FileIO() {
|
public FileIO(String saveLocation) {
|
||||||
String savePath = System.getProperty("user.dir") + File.separator + "tournierverwaltung_angrynerds";
|
this.mainDir = new File(saveLocation);
|
||||||
this.saveDir = new File(savePath);
|
mainDir.mkdir();
|
||||||
saveDir.mkdir();
|
saves = new File(mainDir, "saves");
|
||||||
saves = new File(saveDir, "saves");
|
|
||||||
saves.mkdir();
|
saves.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +33,7 @@ public class FileIO {
|
||||||
ObjectInputStream in = new ObjectInputStream(new FileInputStream(tournamentFile));
|
ObjectInputStream in = new ObjectInputStream(new FileInputStream(tournamentFile));
|
||||||
tournament = (Tournament) in.readObject();
|
tournament = (Tournament) in.readObject();
|
||||||
in.close();
|
in.close();
|
||||||
|
System.out.println("Save File" + tournament.getName() + ".txt being saved to " + saves.getAbsolutePath());
|
||||||
|
|
||||||
} catch (ClassNotFoundException | IOException e) {
|
} catch (ClassNotFoundException | IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
Loading…
Reference in New Issue