public static < T extends SerializableObject > T deserialize ( File file , Class < T > cls ) throws IOException { FileInputStream stream = null ; try { stream = new FileInputStream ( file ) ; DataInputStream in = new DataInputStream ( stream ) ; try { Constructor < T > constructor = cls . getDeclaredConstructor ( DataInput . class ) ; constructor . setAccessible ( true ) ; return constructor . newInstance ( in ) ; } catch ( Exception e ) { throw new IOException ( "Unable to instantiate class: " + cls , e ) ; } } finally { Util . ensureClosed ( stream ) ; } }
Reads an object from a file