类org.apache.commons.io.input.ClassLoaderObjectInputStream源码实例Demo

下面列出了怎么用org.apache.commons.io.input.ClassLoaderObjectInputStream的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jstorm   文件: Utils.java
/**
 * 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);
    }
}
 
public UserEntity deserializeObjectWithInheritance(InputStream receivedFile) throws IOException, ClassNotFoundException {
    ClassLoaderObjectInputStream in = new ClassLoaderObjectInputStream(getClass().getClassLoader(), receivedFile);
    try {
        return (UserEntity) in.readObject();
    }
    finally {
        in.close();
    }
}
 
源代码3 项目: streams   文件: SerializationUtil.java
/**
 * deserialize byte array as Object.
 *
 * <p></p>
 * BORROwED FROM APACHE STORM PROJECT
 *
 * @param serialized byte[]
 * @return Object
 */
public static Object deserialize(byte[] serialized) {
  try {
    ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    ObjectInputStream ois = new ClassLoaderObjectInputStream(classLoader, bis);
    Object ret = ois.readObject();
    ois.close();
    return ret;
  } catch (IOException | ClassNotFoundException ioe) {
    throw new RuntimeException(ioe);
  }
}
 
源代码4 项目: nd4j   文件: VoidMessage.java
static <T extends VoidMessage> T fromBytes(byte[] array) {
    try {
        ObjectInputStream in = new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(),
                        new ByteArrayInputStream(array));

        T result = (T) in.readObject();
        return result;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    //return SerializationUtils.deserialize(array);
}
 
源代码5 项目: deeplearning4j   文件: VoidMessage.java
static <T extends VoidMessage> T fromBytes(byte[] array) {
    try {
        ObjectInputStream in = new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(),
                        new ByteArrayInputStream(array));

        T result = (T) in.readObject();
        return result;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    //return SerializationUtils.deserialize(array);
}
 
源代码6 项目: jstorm   文件: SerializableSerializer.java
@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);
    }
}
 
源代码7 项目: Bats   文件: LogicalPlan.java
public static LogicalPlan read(InputStream is) throws IOException, ClassNotFoundException
{
  return (LogicalPlan)new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(), is).readObject();
}
 
源代码8 项目: attic-apex-core   文件: LogicalPlan.java
public static LogicalPlan read(InputStream is) throws IOException, ClassNotFoundException
{
  return (LogicalPlan)new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(), is).readObject();
}
 
 类所在包
 类方法
 同包方法