Use buffered input/output streams
This commit is contained in:
Binary file not shown.
@@ -1,7 +1,4 @@
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.*;
|
||||
|
||||
public class GraphDataObjectReader {
|
||||
private GraphWithMapData data;
|
||||
@@ -13,7 +10,7 @@ public class GraphDataObjectReader {
|
||||
}
|
||||
this.filename = filename;
|
||||
try(//don't need to close these because of try-with-resources
|
||||
FileInputStream fileIn = new FileInputStream(filename);
|
||||
BufferedInputStream fileIn = new BufferedInputStream(new FileInputStream(filename));
|
||||
ObjectInputStream in = new ObjectInputStream(fileIn))
|
||||
{
|
||||
data = (GraphWithMapData) in.readObject();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
@@ -16,8 +17,8 @@ public class GraphDataObjectWriter {
|
||||
}
|
||||
|
||||
public void writeDataToFile() {
|
||||
try (FileOutputStream fileOut = new FileOutputStream(filename);
|
||||
ObjectOutputStream out = new ObjectOutputStream(fileOut);
|
||||
try (BufferedOutputStream bufferedOut = new BufferedOutputStream(new FileOutputStream(filename));
|
||||
ObjectOutputStream out = new ObjectOutputStream(bufferedOut);
|
||||
){
|
||||
out.writeObject(data);
|
||||
} catch (IOException ex) {
|
||||
|
||||
Reference in New Issue
Block a user