public static String convertSerializableToString ( Serializable obj ) { ByteArrayOutputStream baos = null ; ObjectOutputStream oos = null ; try { baos = new ByteArrayOutputStream ( ) ; oos = new ObjectOutputStream ( baos ) ; oos . writeObject ( obj ) ; return new String ( baos . toByteArray ( ) ) ; } catch ( IOException e ) { return null ; } finally { closeQuietly ( baos , oos ) ; closeQuietly ( oos ) ; } }
Helper method to write a serializable object into a String .