import java.io.*;

public class GraphDataObjectReader {
    private GraphWithMapData data;
    private String filename;

    public GraphDataObjectReader(String filename) throws IOException {
        if(!filename.matches(".*\\.ser")){
            filename = filename + ".ser";
        }
        this.filename = filename;
        try(//don't need to close these because of try-with-resources
            BufferedInputStream fileIn = new BufferedInputStream(new FileInputStream(filename));
                ObjectInputStream in = new ObjectInputStream(fileIn))
        {
            data = (GraphWithMapData) in.readObject();
        } catch (FileNotFoundException | ClassNotFoundException ex) {
            ex.printStackTrace();
        }
    }

    public GraphWithMapData getData() {
        return data;
    }

    public String getFilename() {
        return filename;
    }
}
