Last active
December 31, 2015 20:38
-
-
Save tckb/8041061 to your computer and use it in GitHub Desktop.
Code fragment
This file contains hidden or 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
// Code part of tckb-lib | |
// Author: tckb <[email protected]> | |
// https://github.com/tckb/jAudIO.pub | |
public static void saveObjectToFile(File thatFile, Object... thisObject) { | |
mylogger.log(Level.INFO, "Saving object{0} to file: {1}", new Object[]{thisObject.hashCode(), thatFile.getAbsolutePath()}); | |
ObjectOutputStream stream; | |
try { | |
stream = new ObjectOutputStream(new FileOutputStream(thatFile)); | |
stream.writeObject(thisObject); | |
stream.close(); | |
} catch (IOException ex) { | |
mylogger.log(Level.SEVERE, "Error: Can not save the object!", ex.getMessage()); | |
} | |
} | |
public static Object[] getObjectFromFile(File thatFile) { | |
mylogger.log(Level.INFO, "Extracting object from file: {0}", thatFile.getAbsolutePath()); | |
Object[] thatObject = null; | |
try { | |
ObjectInputStream stream = new ObjectInputStream(new FileInputStream(thatFile)); | |
thatObject = (Object[]) stream.readObject(); | |
stream.close(); | |
} catch (Exception ex) { | |
mylogger.log(Level.SEVERE, "Error: Can not extract the object from file", ex.getMessage()); | |
} | |
return thatObject; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment