本文整理汇总了Java中org.apache.commons.io.input.ClassLoaderObjectInputStream.readObject方法的典型用法代码示例。如果您正苦于以下问题:Java ClassLoaderObjectInputStream.readObject方法的具体用法?Java ClassLoaderObjectInputStream.readObject怎么用?Java ClassLoaderObjectInputStream.readObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.input.ClassLoaderObjectInputStream
的用法示例。
在下文中一共展示了ClassLoaderObjectInputStream.readObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
public static Object deserialize(byte[] serialized, URLClassLoader loader) {
try {
ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
Object ret = null;
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 ioe) {
throw new RuntimeException(ioe);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
示例2: javaDeserializeWithCL
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
/**
* Deserialized with ClassLoader
*
* @param serialized
* @param loader
* @return
*/
public static Object javaDeserializeWithCL(byte[] serialized, URLClassLoader loader) {
try {
ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
Object ret = null;
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 ioe) {
throw new RuntimeException(ioe);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
示例3: loadGameHistory
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
/**
* Loads a saved game from the device's memory
* @return saved match if found, else returns null
*/
public static PygmyGame loadGameHistory(String path) {
File file = new File(path);
PygmyGame game = null;
if (file.exists()) {
try {
ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(
PygmyLoader.getClassLoader(), new FileInputStream(file));
game = (PygmyGame) ois.readObject();
ois.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return game;
}
示例4: javaDeserializeWithCL
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
/**
* 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);
}
}
示例5: restoreWrappedObject
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
private void restoreWrappedObject() {
try {
if(modelObject_ == null) {
// Then this must be a new request
installFacesListener();
ByteArrayInputStream bis = new ByteArrayInputStream(serializedModel_);
FacesContext facesContext = FacesContext.getCurrentInstance();
ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(facesContext.getContextClassLoader(), bis);
modelObject_ = (ModelObject)ois.readObject();
ois.close();
bis.close();
serializedModel_ = null;
}
} catch(Exception e) {
e.printStackTrace();
}
}
示例6: deserializeObjectWithInheritance
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
public UserEntity deserializeObjectWithInheritance(InputStream receivedFile) throws IOException, ClassNotFoundException {
ClassLoaderObjectInputStream in = new ClassLoaderObjectInputStream(getClass().getClassLoader(), receivedFile);
try {
return (UserEntity) in.readObject();
}
finally {
in.close();
}
}
示例7: read
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
@SuppressWarnings("resource")
@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);
}
}
示例8: read
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
@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);
}
}
示例9: read
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
@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);
}
}
示例10: deserialize
import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入方法依赖的package包/类
private Object deserialize(byte[] serializedOriginal, ClassLoader targetLoader) throws ClassNotFoundException, IOException {
ByteArrayInputStream byteStream = new ByteArrayInputStream(serializedOriginal);
ClassLoaderObjectInputStream objectStream = new ClassLoaderObjectInputStream(targetLoader, byteStream);
return objectStream.readObject();
}