Skip to content

Commit 969d66a

Browse files
committed
Added buffers to improve performance
Added buffers to improve performance when loading the storage from file or saving it.
1 parent d3a2858 commit 969d66a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/com/blogspot/debukkitsblog/util/FileStorage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.blogspot.debukkitsblog.util;
22

3+
import java.io.BufferedInputStream;
4+
import java.io.BufferedOutputStream;
35
import java.io.File;
46
import java.io.FileInputStream;
57
import java.io.FileOutputStream;
@@ -75,7 +77,7 @@ public FileStorage(File file) throws IOException, IllegalArgumentException {
7577
* Stores the FileStorage in the file on disk
7678
*/
7779
public void save() throws IOException {
78-
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(storageFile));
80+
ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(storageFile)));
7981
oos.writeObject(storageMap);
8082
oos.flush();
8183
oos.close();
@@ -87,7 +89,7 @@ public void save() throws IOException {
8789
@SuppressWarnings("unchecked")
8890
private void load() {
8991
try {
90-
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(storageFile));
92+
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(storageFile)));
9193
storageMap = (HashMap<String, Object>) ois.readObject();
9294
ois.close();
9395
} catch (Exception e) {

0 commit comments

Comments
 (0)