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.*;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
|
|
||||||
public class GraphDataObjectReader {
|
public class GraphDataObjectReader {
|
||||||
private GraphWithMapData data;
|
private GraphWithMapData data;
|
||||||
@@ -13,7 +10,7 @@ public class GraphDataObjectReader {
|
|||||||
}
|
}
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
try(//don't need to close these because of try-with-resources
|
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))
|
ObjectInputStream in = new ObjectInputStream(fileIn))
|
||||||
{
|
{
|
||||||
data = (GraphWithMapData) in.readObject();
|
data = (GraphWithMapData) in.readObject();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
@@ -16,8 +17,8 @@ public class GraphDataObjectWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeDataToFile() {
|
public void writeDataToFile() {
|
||||||
try (FileOutputStream fileOut = new FileOutputStream(filename);
|
try (BufferedOutputStream bufferedOut = new BufferedOutputStream(new FileOutputStream(filename));
|
||||||
ObjectOutputStream out = new ObjectOutputStream(fileOut);
|
ObjectOutputStream out = new ObjectOutputStream(bufferedOut);
|
||||||
){
|
){
|
||||||
out.writeObject(data);
|
out.writeObject(data);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user