36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
import java.io.*;
|
|
|
|
public class GraphDataObjectReader {
|
|
|
|
private GraphWithMapData data;
|
|
private String filename;
|
|
|
|
|
|
public GraphDataObjectReader(String filename, boolean verbose) 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))
|
|
{
|
|
if (verbose) {
|
|
System.out.println("Reading graph data from file. This may take some time");
|
|
System.out.println("File I/O time is not included in results");
|
|
}
|
|
data = (GraphWithMapData) in.readObject();
|
|
} catch (FileNotFoundException | ClassNotFoundException ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public GraphWithMapData getData() {
|
|
return data;
|
|
}
|
|
|
|
public String getFilename() {
|
|
return filename;
|
|
}
|
|
}
|