List of usage examples for java.io ObjectInput readObject
public Object readObject() throws ClassNotFoundException, IOException;
From source file:Main.java
public static Object ByteToObject(byte[] bytes) { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInput in = null; try {/*from www .j a v a 2 s . c o m*/ in = new ObjectInputStream(bis); } catch (StreamCorruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Object obj = null; try { obj = in.readObject(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return obj; }
From source file:wvec.WordVec.java
static WordVec decodeFromByteArray(BytesRef bytes) throws Exception { ObjectInput in; Object o;/* w w w . ja v a 2 s. c o m*/ try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes.bytes)) { in = new ObjectInputStream(bis); o = in.readObject(); } in.close(); return (WordVec) o; }
From source file:io.bitsquare.common.util.Utilities.java
public static <T extends Serializable> T deserialize(byte[] data) { ByteArrayInputStream bis = new ByteArrayInputStream(data); ObjectInput in = null; Object result = null;// ww w. java2 s . c o m try { in = new LookAheadObjectInputStream(bis, true); result = in.readObject(); if (!(result instanceof Serializable)) throw new RuntimeException("Object not of type Serializable"); } catch (Exception e) { e.printStackTrace(); } finally { try { bis.close(); } catch (IOException ex) { // ignore close exception } try { if (in != null) { in.close(); } } catch (IOException ex) { // ignore close exception } } return (T) result; }
From source file:com.act.reachables.Network.java
public static Network deserialize(String fromFile) { try {/*from ww w. j av a2 s .com*/ InputStream file = new FileInputStream(fromFile); InputStream buffer = new BufferedInputStream(file); ObjectInput input = new ObjectInputStream(buffer); try { return (Network) input.readObject(); } finally { input.close(); } } catch (ClassNotFoundException ex) { throw new RuntimeException("Network deserialize failed: Class not found: " + ex); } catch (IOException ex) { throw new RuntimeException("Network deserialize failed: IO problem: " + ex); } }
From source file:net.brtly.monkeyboard.api.plugin.Bundle.java
/** * Factory method that creates a Bundle by deserializing a byte array * produced by {@link #toByteArray(Bundle)} * // w ww .j a v a 2s . c o m * @param b * @return * @throws IOException * @throws ClassNotFoundException */ public static Bundle fromByteArray(byte[] b) throws IOException, ClassNotFoundException { ByteArrayInputStream bis = new ByteArrayInputStream(b); ObjectInput in = null; try { in = new ObjectInputStream(bis); return (Bundle) in.readObject(); } finally { bis.close(); in.close(); } }
From source file:MainClass.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { System.out.println("MyBean.readExternal"); s = (String) in.readObject(); i = in.readInt();// ww w. j a va2 s. c o m }
From source file:Blip3.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { System.out.println("Blip3.readExternal"); // You must do this: s = (String) in.readObject(); i = in.readInt();//from w ww .j av a 2s . com }
From source file:com.github.catageek.bytecart.routing.Metric.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { delay = (Delay) in.readObject(); }
From source file:org.drools.CheeseEqual.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { type = (String) in.readObject(); price = in.readInt();/*from w w w . j av a 2 s . c o m*/ }
From source file:org.codehaus.wadi.servicespace.InvocationInfo.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { targetClass = (Class) in.readObject(); memberUpdaterIndex = in.readInt();/* w ww . j a va 2 s . c om*/ params = (Object[]) in.readObject(); metaData = (InvocationMetaData) in.readObject(); }