use of java.io.ObjectInputStream in project lucida by claritylab.
the class ScoreNormalizationFilter method readSerializedResults.
/**
* Reads serialized results from a file.
*
* @param input input file
* @return result objects
*/
private static Result[] readSerializedResults(File input) {
ArrayList<Result> results = new ArrayList<Result>();
try {
FileInputStream fis = new FileInputStream(input);
ObjectInputStream ois = new ObjectInputStream(fis);
// then discard it
if (!(ois.readObject() instanceof AnalyzedQuestion)) {
MsgPrinter.printErrorMsg("First serialized object is not an" + "AnalyzedQuestion.");
System.exit(1);
}
try {
while (true) results.add((Result) ois.readObject());
} catch (EOFException e) {
/* end of file reached */
}
ois.close();
} catch (Exception e) {
MsgPrinter.printErrorMsg("Could not read serialized results:");
MsgPrinter.printErrorMsg(e.toString());
System.exit(1);
}
return results.toArray(new Result[results.size()]);
}
use of java.io.ObjectInputStream in project neo4j by neo4j.
the class MemberIsUnavailableTest method deserialize.
private static MemberIsUnavailable deserialize(byte[] serialized) throws Exception {
ObjectInputStream inputStream = null;
try {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(serialized);
inputStream = new ObjectStreamFactory().create(byteArrayInputStream);
return (MemberIsUnavailable) inputStream.readObject();
} finally {
if (inputStream != null) {
inputStream.close();
}
}
}
use of java.io.ObjectInputStream in project zipkin by openzipkin.
the class SpanTest method serialization.
@Test
public void serialization() throws Exception {
Span span = TestObjects.TRACE.get(0);
Buffer buffer = new Buffer();
new ObjectOutputStream(buffer.outputStream()).writeObject(span);
assertThat(new ObjectInputStream(buffer.inputStream()).readObject()).isEqualTo(span);
}
use of java.io.ObjectInputStream in project jodd by oblac.
the class ObjectUtil method readObject.
/**
* Reads serialized object from the file.
*/
public static Object readObject(File source) throws IOException, ClassNotFoundException {
Object result = null;
FileInputStream fis = null;
BufferedInputStream bis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(source);
bis = new BufferedInputStream(fis);
ois = new ObjectInputStream(bis);
result = ois.readObject();
} finally {
StreamUtil.close(ois);
StreamUtil.close(bis);
StreamUtil.close(fis);
}
return result;
}
use of java.io.ObjectInputStream in project jodd by oblac.
the class ObjectUtil method byteArrayToObject.
/**
* De-serialize an object from byte array.
*/
public static Object byteArrayToObject(byte[] data) throws IOException, ClassNotFoundException {
Object retObj = null;
ByteArrayInputStream bais = new ByteArrayInputStream(data);
ObjectInputStream ois = null;
try {
ois = new ObjectInputStream(bais);
retObj = ois.readObject();
} finally {
StreamUtil.close(ois);
}
return retObj;
}
Aggregations