List of usage examples for java.io ObjectInputStream close
public void close() throws IOException
From source file:Main.java
public static Object stm2obj(InputStream f) throws IOException, ClassNotFoundException { ObjectInputStream oo = new ObjectInputStream(f); try {/*from w w w .j av a2 s .c o m*/ return oo.readObject(); } finally { oo.close(); } }
From source file:Main.java
public static Object readObj(String fileName) { Object obj = new Object(); try {/*w w w .ja v a2 s . c o m*/ FileInputStream fin = new FileInputStream(fileName); ObjectInputStream oin = new ObjectInputStream(fin); obj = oin.readObject(); fin.close(); oin.close(); } catch (Exception e) { printE("OpusTool", e); } finally { return obj; } }
From source file:Main.java
public static Object deserializeObject(byte[] b) { try {/*from www .j av a 2s .c o m*/ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(b)); Object object = in.readObject(); in.close(); return object; } catch (ClassNotFoundException cnfe) { // Log.e("deserializeObject", "class not found error", cnfe); return null; } catch (IOException ioe) { // Log.e("deserializeObject", "io error", ioe); return null; } }
From source file:Main.java
public static Object deserializeObject(byte[] b) { try {//from w w w . j av a 2s. c o m ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(b)); Object object = in.readObject(); in.close(); return object; } catch (ClassNotFoundException cnfe) { Log.e("deserializeObject", "class not found error", cnfe); return null; } catch (IOException ioe) { Log.e("deserializeObject", "io error", ioe); return null; } }
From source file:Main.java
public static Object StringToObject(String str) throws Exception { byte[] data = Base64.decode(str, 0); ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(data)); Object object = objectInputStream.readObject(); objectInputStream.close(); return object; }
From source file:com.mayalogy.mayu.io.LocalDataManager.java
public static Object readFromFileAndDeserialize(String inFile) throws ClassNotFoundException, IOException { FileInputStream fin = new FileInputStream(inFile); ObjectInputStream ois = new ObjectInputStream(fin); Object oRead = ois.readObject(); ois.close(); return oRead; }
From source file:Main.java
public static Object deSerialization(String str) throws IOException, ClassNotFoundException { byte[] mobileBytes = Base64.decode(str.getBytes(), Base64.DEFAULT); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(mobileBytes); ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); Object object = (Object) objectInputStream.readObject(); objectInputStream.close(); return object; }
From source file:com.mayalogy.mayu.io.LocalDataManager.java
public static Object readFromJarAndDeserialize(String resourceName) throws ClassNotFoundException, IOException { InputStream is = Class.class.getResourceAsStream("/" + resourceName); if (is == null) { //Used for when jar is running in a servlet ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); is = classLoader.getResourceAsStream(resourceName); }/*from ww w .j av a 2 s .c o m*/ ObjectInputStream ois = new ObjectInputStream(is); Object oRead = ois.readObject(); ois.close(); return oRead; }
From source file:Main.java
public static List String2SceneList(String SceneListString) throws IOException, ClassNotFoundException { byte[] mobileBytes = Base64.decode(SceneListString.getBytes(), Base64.DEFAULT); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(mobileBytes); ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); List SceneList = (List) objectInputStream.readObject(); objectInputStream.close(); return SceneList; }
From source file:IO.serializer.java
public static Object Deserialize(String objectFilename, boolean deleteSerialized) { String serializedFilename = String.format("%s\\%s.%s", m_systemTempDirectory, objectFilename, m_serializedFileExtension);/*from w w w . ja va 2 s. c o m*/ Object serialized = null; if (Files.IsFile(serializedFilename)) { try (FileInputStream fin = new FileInputStream(serializedFilename)) { ObjectInputStream ois = new ObjectInputStream(fin); serialized = ois.readObject(); ois.close(); } catch (IOException | ClassNotFoundException ex) { Console.PrintLine( String.format("Error deserilizing object '%s': %s", objectFilename, ex.getMessage()), true, false); } } return serialized; }