ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(validator); oos.flush(); oos.close(); } catch (Exception e) { }