Skip to content

Commit

Permalink
using Buffered Streams in blocking tree read/write #82
Browse files Browse the repository at this point in the history
  • Loading branch information
navinrathore committed Jan 11, 2022
1 parent f1c6a28 commit d70ef74
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/src/main/java/zingg/client/util/Util.java
@@ -1,5 +1,7 @@
package zingg.client.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down Expand Up @@ -473,16 +475,18 @@ public static Dataset<Row> addUniqueCol(Dataset<Row> dupesActual, String colName

public static byte[] convertObjectIntoByteArray(Object obj) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
BufferedOutputStream bufferedOS = new BufferedOutputStream(bos);
ObjectOutputStream oos = new ObjectOutputStream(bufferedOS);
oos.writeObject(obj);
oos.flush();
return bos.toByteArray();
}

public static Object revertObjectFromByteArray(byte[] byteArray) throws IOException, ClassNotFoundException {
ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(bis);
return ois.readObject();
BufferedInputStream bufferedIS = new BufferedInputStream(bis);
ObjectInputStream ois = new ObjectInputStream(bufferedIS);
return ois.readObject();
}

}

0 comments on commit d70ef74

Please sign in to comment.