Created
June 7, 2014 10:32
-
-
Save dsaiztc/3137780cdd49a97591b2 to your computer and use it in GitHub Desktop.
Converts byte[] to object.
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
/** | |
* Converts an object in byte[] to Object | |
* | |
* @param object Object in byte[] | |
* @return The original Object | |
*/ | |
public static Object byteToObject(byte[] object) | |
{ | |
Object result = null; | |
ByteArrayInputStream bis = new ByteArrayInputStream(object); | |
ObjectInput in = null; | |
try | |
{ | |
in = new ObjectInputStream(bis); | |
result = in.readObject(); | |
} | |
catch (Exception ioe) | |
{ | |
Log.e(TAG, ioe.toString()); | |
} | |
finally | |
{ | |
try | |
{ | |
bis.close(); | |
} | |
catch (IOException ex) | |
{ | |
Log.e(TAG, ex.toString()); | |
} | |
try | |
{ | |
if (in != null) | |
{ | |
in.close(); | |
} | |
} | |
catch (IOException ex) | |
{ | |
Log.e(TAG, ex.toString()); | |
} | |
} | |
return object; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment