Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static byte[] convertToBytes(Object obj) throws IOException
- {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ObjectOutputStream toWrite = new ObjectOutputStream(output);
- toWrite.writeObject(obj);
- return output.toByteArray();
- }
- public static Object convertFromBytes(byte[] bytes) throws ClassNotFoundException, IOException
- {
- ByteArrayInputStream input = new ByteArrayInputStream(bytes);
- ObjectInputStream toRead = new ObjectInputStream(input);
- return toRead.readObject();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement