use of java.io.ObjectInputStream in project mybatis-3 by mybatis.
the class SerializableProxyTest method deserialize.
protected Serializable deserialize(byte[] value) throws Exception {
ByteArrayInputStream bis = new ByteArrayInputStream(value);
ObjectInputStream ois = new ObjectInputStream(bis);
Serializable result = (Serializable) ois.readObject();
ois.close();
return result;
}
use of java.io.ObjectInputStream in project XobotOS by xamarin.
the class SimpleDateFormat method readObject.
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = stream.readFields();
int version = fields.get("serialVersionOnStream", 0);
Date date;
if (version > 0) {
date = (Date) fields.get("defaultCenturyStart", new Date());
} else {
date = new Date();
}
set2DigitYearStart(date);
formatData = (DateFormatSymbols) fields.get("formatData", null);
pattern = (String) fields.get("pattern", "");
}
use of java.io.ObjectInputStream in project OpenAM by OpenRock.
the class IOUtils method deserialise.
/**
* Deserialises an object from a byte array to an object of a specified type.
*
* @param bytes The bytes that represent the Object to be deserialized. The classes to be loaded must be from the
* set specified in the whitelist maintained in the <code>WhitelistObjectInputStream</code>
* @param compressed If true, expect that the bytes are compressed.
* @param classLoader Used in place of the default ClassLoader, default will be used if null.
* @param <T> The returned object type.
* @return The Object T representing the deserialized bytes
* @throws IOException If there was a problem with the ObjectInputStream process.
* @throws ClassNotFoundException If there was problem loading a class that makes up the bytes to be deserialized.
*/
public static <T> T deserialise(byte[] bytes, boolean compressed, ClassLoader classLoader) throws IOException, ClassNotFoundException {
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final ObjectInputStream ois = compressed ? new WhitelistObjectInputStream(new InflaterInputStream(bais), classLoader) : new WhitelistObjectInputStream(bais, classLoader);
final T result;
try {
result = (T) ois.readObject();
} finally {
closeIfNotNull(ois);
}
return result;
}
use of java.io.ObjectInputStream in project OpenAM by OpenRock.
the class GrammarInfoImpl method getGrammar.
/**
* Gets the MSV AGM which can be used to validate XML during
* marshalling/unmarshalling.
*/
public final com.sun.msv.grammar.Grammar getGrammar() throws JAXBException {
try {
InputStream is = objectFactoryClass.getResourceAsStream("bgm.ser");
if (is == null) {
// unable to find bgm.ser
String name = objectFactoryClass.getName();
int idx = name.lastIndexOf('.');
name = '/' + name.substring(0, idx + 1).replace('.', '/') + "bgm.ser";
throw new JAXBException(Messages.format(Messages.NO_BGM, name));
}
// deserialize the bgm
ObjectInputStream ois = new ObjectInputStream(is);
com.sun.xml.bind.GrammarImpl g = (com.sun.xml.bind.GrammarImpl) ois.readObject();
ois.close();
// connect to itself
g.connect(new com.sun.msv.grammar.Grammar[] { g });
return g;
} catch (Exception e) {
throw new JAXBException(Messages.format(Messages.UNABLE_TO_READ_BGM), e);
}
}
use of java.io.ObjectInputStream in project android_frameworks_base by ResurrectionRemix.
the class RationalTest method deserialize.
private static <T extends Serializable> T deserialize(byte[] array, Class<T> klass) throws IOException, ClassNotFoundException {
ByteArrayInputStream bais = new ByteArrayInputStream(array);
ObjectInputStream ois = new ObjectInputStream(bais);
Object obj = ois.readObject();
return klass.cast(obj);
}
Aggregations