Serializer - return r; } public Object materialize(byte...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
, import java.io.*; i public class Serializer{ p public byte[] dematerialize(Object obj){ byte[] r=null; try{ ByteArrayOutputStream baos=new ByteArrayOutputStream(); ObjectOutputStream oos=new ObjectOutputStream(baos); oos.writeObject(obj); oos.flush(); r=baos.toByteArray(); } catch(Exception e){e.printStackTrace();}
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return r; } public Object materialize(byte bytes){ Object r=null; try{ ByteArrayInputStream bais=new ByteArrayInputStream(bytes); ObjectInputStream ois=new ObjectInputStream(bais); r=ois.readObject(); ois.close(); bais.close(); } catch(Exception e){e.printStackTrace();} return r; } }...
View Full Document

This note was uploaded on 04/26/2010 for the course COMPUTER S Java2 taught by Professor Kwstasmixail during the Spring '10 term at Technical University of Crete.

Ask a homework question - tutors are online