changes so that savepath can be set elsewhere
This commit is contained in:
parent
e1fdc5deac
commit
380250f60e
|
@ -15,7 +15,7 @@ public class App {
|
|||
public static void main(String[] args) {
|
||||
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");
|
||||
io.saveTournament(tournament);
|
||||
|
||||
|
|
|
@ -1,21 +1,25 @@
|
|||
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.List;
|
||||
|
||||
|
||||
public class FileIO {
|
||||
File saveDir;
|
||||
File saves;
|
||||
private File mainDir;
|
||||
private File saves;
|
||||
|
||||
|
||||
public FileIO() {
|
||||
String savePath = System.getProperty("user.dir") + File.separator + "tournierverwaltung_angrynerds";
|
||||
this.saveDir = new File(savePath);
|
||||
saveDir.mkdir();
|
||||
saves = new File(saveDir, "saves");
|
||||
public FileIO(String saveLocation) {
|
||||
this.mainDir = new File(saveLocation);
|
||||
mainDir.mkdir();
|
||||
saves = new File(mainDir, "saves");
|
||||
saves.mkdir();
|
||||
}
|
||||
|
||||
|
@ -29,6 +33,7 @@ public class FileIO {
|
|||
ObjectInputStream in = new ObjectInputStream(new FileInputStream(tournamentFile));
|
||||
tournament = (Tournament) in.readObject();
|
||||
in.close();
|
||||
System.out.println("Save File" + tournament.getName() + ".txt being saved to " + saves.getAbsolutePath());
|
||||
|
||||
} catch (ClassNotFoundException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
Loading…
Reference in New Issue