/** * {@inheritDoc} */ @Override public void close() throws IOException { this.in.close(); }
@Override public void close() throws IOException { in.close(); }
@Override public void close() throws IOException { in.close(); }
ByteArrayInputStream bis = new ByteArrayInputStream(yourBytes); ObjectInput in = null; try { in = new ObjectInputStream(bis); Object o = in.readObject(); ... } finally { try { if (in != null) { in.close(); } } catch (IOException ex) { // ignore close exception } }
static <T> T read(String s) { try { ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(Base64.decodeBase64(s))); try { return (T) in.readObject(); } finally { in.close(); } } catch( Exception ex ) { throw Log.errRTExcept(ex); } } }
public static Serializable deserialize( byte[] byteArray, ClassLoader classLoader ) throws IOException, ClassNotFoundException { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); ByteArrayInputStream byteArrayIn = new ByteArrayInputStream(byteArray); ObjectInput objectIn = null; Serializable result; try { objectIn = new ObjectInputStream(byteArrayIn); result = (Serializable) objectIn.readObject(); } finally { try { byteArrayIn.close(); } catch( IOException ex ) { // ignore close exception } try { if( objectIn != null ) { objectIn.close(); } } catch( IOException ex ) { // ignore close exception } Thread.currentThread().setContextClassLoader(originalClassLoader); } return result; }
ObjectInput oo = new CustomObjectInputStream(classLoaderCodec.getClassLoader(), is); task = (T) oo.readObject(); oo.close(); } else { task = (T) classLoaderCodec.getValueDecoder().decode(stateBuf, null);
ObjectInput oo = new CustomObjectInputStream(classLoaderCodec.getClassLoader(), is); task = (T) oo.readObject(); oo.close(); } else { task = (T) classLoaderCodec.getValueDecoder().decode(stateBuf, null);
private Object decodeRequest(byte[] body, long requestId, Serialization serialization) throws IOException, ClassNotFoundException { ByteArrayInputStream inputStream = new ByteArrayInputStream(body); ObjectInput input = createInput(inputStream); String interfaceName = input.readUTF(); String methodName = input.readUTF(); String paramtersDesc = input.readUTF(); DefaultRequest rpcRequest = new DefaultRequest(); rpcRequest.setRequestId(requestId); rpcRequest.setInterfaceName(interfaceName); rpcRequest.setMethodName(methodName); rpcRequest.setParamtersDesc(paramtersDesc); rpcRequest.setArguments(decodeRequestParameter(input, paramtersDesc, serialization)); rpcRequest.setAttachments(decodeRequestAttachments(input)); input.close(); return rpcRequest; }
private Object decodeResponse(byte[] body, byte dataType, long requestId, Serialization serialization) throws IOException, ClassNotFoundException { ByteArrayInputStream inputStream = new ByteArrayInputStream(body); ObjectInput input = createInput(inputStream); long processTime = input.readLong(); DefaultResponse response = new DefaultResponse(); response.setRequestId(requestId); response.setProcessTime(processTime); if (dataType == MotanConstants.FLAG_RESPONSE_VOID) { return response; } String className = input.readUTF(); Class<?> clz = ReflectUtil.forName(className); Object result = deserialize((byte[]) input.readObject(), clz, serialization); if (dataType == MotanConstants.FLAG_RESPONSE) { response.setValue(result); } else if (dataType == MotanConstants.FLAG_RESPONSE_EXCEPTION) { response.setException((Exception) result); } else { throw new MotanFrameworkException("decode error: response dataType not support " + dataType, MotanErrorMsgConstant.FRAMEWORK_DECODE_ERROR); } response.setRequestId(requestId); input.close(); return response; }
rpcRequest.setRpcProtocolVersion(RpcProtocolVersion.VERSION_2.getVersion()); input.close(); Map<String, String> attachments = rpcRequest.getAttachments();
input.close();
private Object deserialize(byte[] bytes) throws IOException { final ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInput in = null; try { in = new ObjectInputStream(bis); return in.readObject(); } catch (final ClassNotFoundException e) { throw Unchecked.translateCheckedException(e); } finally { if (in != null) { in.close(); } } }
private Collection<KiePackage> _deserializeFromBytes(byte [] byteCode){ Collection<KiePackage> ret = null; ByteArrayInputStream bis = null; ObjectInput in = null; try { bis = new ByteArrayInputStream(byteCode); in = new DroolsObjectInputStream(bis); ret =(Collection<KiePackage>)in.readObject(); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if(bis != null) bis.close(); if(in != null) in.close(); } catch (IOException e) { } } return ret; } }
public void close() throws IOException { in.close(); } }
InputStream file = new FileInputStream("quarks.ser"); InputStream buffer = new BufferedInputStream(file); ObjectInput input = new ObjectInputStream (buffer); try{ //do sth throw new RuntimeException(); //do sth else } finally{ input.close(); }
public class MyShop { private MyShop readShop; public MyShop getReadShop() { return readShop; } public void loadShop(String fName) { try { ObjectInput out = new ObjectInputStream(new FileInputStream(filename)); this.readShop = (MyShop)out.readObject(); out.close(); } catch (Exception e) { throw new RuntimeException(e); } }
HashMap<K, V> map = new HashMap<K, V>(); //Write: OutputStream os = new FileOutputStream(fileName.ser); ObjectOutput oo = new ObjectOutputStream(os); oo.writeObject(map); oo.close(); //Read: InputStream is = new FileInputStream(fileName.ser); ObjectInput oi = new ObjectInputStream(is); HashMap<K, V> newMap = oi.readObject(); oi.close();
public void close() throws IOException { trace("start close()"); oi.close(); trace("end close()"); }
public void close() throws IOException { trace("start close()"); oi.close(); trace("end close()"); }