List of usage examples for java.io ObjectInputStream readObject
public final Object readObject() throws IOException, ClassNotFoundException
From source file:com.jaspersoft.jasperserver.core.util.StreamUtil.java
public static Object uncompressObject(byte[] compressed) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(compressed); GZIPInputStream gzis = new GZIPInputStream(bais); ObjectInputStream ois = new ObjectInputStream(gzis); return ois.readObject(); }
From source file:Main.java
public static Object readObject(Context context, String filename) { FileInputStream in = null;/* w ww. j a va 2 s .co m*/ ObjectInputStream oin = null; Object data = null; try { in = context.openFileInput(filename + ".odb"); oin = new ObjectInputStream(in); data = oin.readObject(); oin.close(); in.close(); } catch (Exception e) { e.printStackTrace(); } return data; }
From source file:io.lqd.sdk.model.LQLiquidPackage.java
public static LQLiquidPackage loadFromDisk(Context context) { LQLog.data("Loading from local storage"); try {/* www.java 2 s . com*/ FileInputStream fileInputStream = context.openFileInput(LIQUID_PACKAGE_FILENAME + ".vars"); ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); Object result = objectInputStream.readObject(); objectInputStream.close(); return (LQLiquidPackage) result; } catch (IOException e) { LQLog.infoVerbose("Could not load liquid package from file"); } catch (ClassNotFoundException e) { LQLog.infoVerbose("Could not load liquid package from file"); } return new LQLiquidPackage(); }
From source file:Main.java
public static Object readObjectFromFile(String fileName) { ObjectInputStream ois = null; FileInputStream fis = null;/* ww w . j a va 2s . c o m*/ try { fis = new FileInputStream(fileName); ois = new ObjectInputStream(fis); return ois.readObject(); } catch (Exception e) { } finally { if (ois != null) try { ois.close(); ois = null; } catch (IOException e) { } if (fis != null) try { fis.close(); fis = null; } catch (IOException e) { } } return null; }
From source file:jedi.util.serialization.Pickle.java
/** * Receives a sequence of bytes and returns a object. * //w w w . j a v a2s . c o m * @param s Sequence of bytes. * @return Object */ public static Object loads(String s) { Object o = null; ByteArrayInputStream bais; try { bais = new ByteArrayInputStream(Base64.decodeBase64(s.getBytes())); ObjectInputStream ois = new ObjectInputStream(bais); o = ois.readObject(); ois.close(); bais.close(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return o; }
From source file:jedi.util.serialization.Pickle.java
/** * Deserializes objects./*from w ww . ja v a2s.com*/ * * @param f File that holds the serialized objects. * @return Object */ public static Object load(File f) { Object o = null; if (f != null) { try { FileInputStream fis = new FileInputStream(f); // The file reader. ObjectInputStream ois = new ObjectInputStream(fis); o = ois.readObject(); ois.close(); fis.close(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } return o; }
From source file:de.tudarmstadt.ukp.experiments.argumentation.comments.pipeline.ExtendedMalletTopicModelEstimator.java
/** * Loads serialized vocabulary ({@code HashMap<String, Integer>}) from file * * @return vocabulary entries (key set)/* ww w. ja va2s. co m*/ * @throws IOException * @throws ClassNotFoundException */ @SuppressWarnings("unchecked") public static Set<String> readVocabulary(File vocabularyFile) throws IOException, ClassNotFoundException { ObjectInputStream ois = new ObjectInputStream(new FileInputStream(vocabularyFile)); Map<String, Integer> map = (Map<String, Integer>) ois.readObject(); IOUtils.closeQuietly(ois); return map.keySet(); }
From source file:com.nextgis.maplib.datasource.GeoGeometry.java
public static GeoGeometry fromBlob(byte[] raw) throws IOException, ClassNotFoundException { ByteArrayInputStream in = new ByteArrayInputStream(raw); ObjectInputStream is = new ObjectInputStream(in); return (GeoGeometry) is.readObject(); }
From source file:com.fengduo.bee.commons.util.ObjectUtils.java
/** * ???// ww w.j ava 2s. c om * * @param bytes * @return */ public static Object unserialize(byte[] bytes) { ByteArrayInputStream bais = null; try { if (bytes != null && bytes.length > 0) { bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); return ois.readObject(); } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.cloudera.kitten.util.LocalDataHelper.java
public static <T> Map<String, T> deserialize(String serialized) { byte[] data = Base64.decodeBase64(serialized); ByteArrayInputStream bais = new ByteArrayInputStream(data); Map<String, T> mapping = null; try {/*w w w . j a v a 2s . com*/ ObjectInputStream ois = new ObjectInputStream(bais); mapping = (Map<String, T>) ois.readObject(); ois.close(); } catch (Exception e) { throw new RuntimeException(e); } return mapping; }