Java Code Examples for org.apache.commons.io.input.ClassLoaderObjectInputStream#readObject()
The following examples show how to use
org.apache.commons.io.input.ClassLoaderObjectInputStream#readObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From jstorm with Apache License 2.0 | 6 votes |
/** * Deserialized with ClassLoader */ public static Object javaDeserializeWithCL(byte[] serialized, URLClassLoader loader) { try { ByteArrayInputStream bis = new ByteArrayInputStream(serialized); Object ret; if (loader != null) { ClassLoaderObjectInputStream cis = new ClassLoaderObjectInputStream(loader, bis); ret = cis.readObject(); cis.close(); } else { ObjectInputStream ois = new ObjectInputStream(bis); ret = ois.readObject(); ois.close(); } return ret; } catch (IOException | ClassNotFoundException ioe) { throw new RuntimeException(ioe); } }
Example 2
Source File: ObjectDeserialization.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
public UserEntity deserializeObjectWithInheritance(InputStream receivedFile) throws IOException, ClassNotFoundException { ClassLoaderObjectInputStream in = new ClassLoaderObjectInputStream(getClass().getClassLoader(), receivedFile); try { return (UserEntity) in.readObject(); } finally { in.close(); } }
Example 3
Source File: SerializableSerializer.java From jstorm with Apache License 2.0 | 5 votes |
@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 { ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(kryo.getClassLoader(), bis); return ois.readObject(); } catch (Exception e) { throw new RuntimeException(e); } }