public String serialize ( Object object ) { ObjectOutputStream oos = null ; ByteArrayOutputStream bos = null ; try { bos = new ByteArrayOutputStream ( ) ; oos = new ObjectOutputStream ( bos ) ; oos . writeObject ( object ) ; return new String ( Base64 . encodeBase64 ( bos . toByteArray ( ) ) ) ; } catch ( IOException e ) { LOGGER . error ( "Can't serialize data on Base 64" , e ) ; throw new IllegalArgumentException ( e ) ; } catch ( Exception e ) { LOGGER . error ( "Can't serialize data on Base 64" , e ) ; throw new IllegalArgumentException ( e ) ; } finally { try { if ( bos != null ) { bos . close ( ) ; } } catch ( Exception e ) { LOGGER . error ( "Can't close ObjetInputStream used for serialize data on Base 64" , e ) ; } } }
Serialize object to an encoded base64 string .