Skip to content

Commit

Permalink
Added buffers to improve performance
Browse files Browse the repository at this point in the history
Added buffers to improve performance when loading the storage from file or saving it.
  • Loading branch information
DeBukkIt committed Feb 28, 2018
1 parent d3a2858 commit 969d66a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/com/blogspot/debukkitsblog/util/FileStorage.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.blogspot.debukkitsblog.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -75,7 +77,7 @@ public FileStorage(File file) throws IOException, IllegalArgumentException {
* Stores the FileStorage in the file on disk
*/
public void save() throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(storageFile));
ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(storageFile)));
oos.writeObject(storageMap);
oos.flush();
oos.close();
Expand All @@ -87,7 +89,7 @@ public void save() throws IOException {
@SuppressWarnings("unchecked")
private void load() {
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(storageFile));
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(storageFile)));
storageMap = (HashMap<String, Object>) ois.readObject();
ois.close();
} catch (Exception e) {
Expand Down

0 comments on commit 969d66a

Please sign in to comment.