use of java.io.ObjectInputStream in project mybatis-3 by mybatis.
the class UtilityTester method deserialzeObject.
private static Object deserialzeObject(byte[] aSerializedObject) {
try {
// Deserialize from a byte array
ObjectInputStream myObjectInputStream = new ObjectInputStream(new ByteArrayInputStream(aSerializedObject));
Object myResult = myObjectInputStream.readObject();
myObjectInputStream.close();
return myResult;
} catch (Exception anException) {
throw new RuntimeException("Problem deserializing", anException);
}
}
use of java.io.ObjectInputStream in project mybatis-3 by mybatis.
the class LazyDeserializeTest method deserializeFoo.
private LazyObjectFoo deserializeFoo(final byte[] serializedFoo) throws Exception {
final ByteArrayInputStream bis = new ByteArrayInputStream(serializedFoo);
final ObjectInputStream ios = new ObjectInputStream(bis);
final LazyObjectFoo foo = LazyObjectFoo.class.cast(ios.readObject());
ios.close();
return foo;
}
use of java.io.ObjectInputStream in project storm by nathanmarz.
the class Utils method deserialize.
public static Object deserialize(byte[] serialized) {
try {
ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
ObjectInputStream ois = new ObjectInputStream(bis);
Object ret = ois.readObject();
ois.close();
return ret;
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
use of java.io.ObjectInputStream in project storm by nathanmarz.
the class SerializableSerializer method read.
@Override
public Object read(Kryo kryo, Input input, Class c) {
int len = input.readInt();
byte[] ser = new byte[len];
input.readBytes(ser);
ByteArrayInputStream bis = new ByteArrayInputStream(ser);
try {
ObjectInputStream ois = new ObjectInputStream(bis);
return ois.readObject();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of java.io.ObjectInputStream in project jersey by jersey.
the class ReadWriteLockDataStore method deserialize.
/**
* Deserializes an {@code Optional<Object>} from the given stream.
* <p/>
* The given stream will not be close.
*
* @param input the serialized object input stream, must not be null
* @return the serialized object
* @throws IOException in case the load operation failed
**/
private static Optional<Object> deserialize(InputStream input) throws IOException {
try {
BufferedInputStream bis = new BufferedInputStream(input);
ObjectInputStream ois = new ObjectInputStream(bis);
return Optional.of(ois.readObject());
} catch (ClassNotFoundException ex) {
LOG.error("An error occurred during deserialization an object.", ex);
}
return Optional.empty();
}
Aggregations