Last active
October 21, 2015 15:10
-
-
Save mrWinston/f59c16183fa5801fec4a to your computer and use it in GitHub Desktop.
Java Deserializing from File #java #serialization #file #stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This program is free software. It comes without any warranty, to | |
* the extent permitted by applicable law. You can redistribute it | |
* and/or modify it under the terms of the Do What The Fuck You Want | |
* To Public License, Version 2, as published by Sam Hocevar. See | |
* http://www.wtfpl.net/ for more details. | |
*/ | |
try{ | |
FileInputStream fileIn = new FileInputStream("object.ser"); | |
ObjectInputStream in = new ObjectInputStream(fileIn); | |
Object o = (Object) in.readObject(); | |
in.close(); | |
fileIn.close(); | |
}catch(IOException ioe){ | |
throw new RuntimeException("Error while loading Object!", ioe); | |
}catch(ClassNotFoundException cnfe){ | |
throw new RuntimeException("Error while loading Object!", cnfe); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment