public static byte [ ] serObjByte ( Object pk ) throws IOException { final boolean trace = TraceComponent . isAnyTracingEnabled ( ) ; if ( trace && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "serObjByte" , pk == null ? null : pk . getClass ( ) ) ; byte [ ] b ; try { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ObjectOutputStream out = new ObjectOutputStream ( bos ) ; out . writeObject ( pk ) ; out . flush ( ) ; out . close ( ) ; b = bos . toByteArray ( ) ; } catch ( IOException e ) { FFDCFilter . processException ( e , Utils . class . getName ( ) , "336" ) ; if ( trace && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "serObjByte" , new Object [ ] { "Unable to serialize: " + pk , e } ) ; throw e ; } catch ( Error e ) { FFDCFilter . processException ( e , Utils . class . getName ( ) , "342" ) ; if ( trace && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "serObjByte" , new Object [ ] { "Unable to serialize: " + pk , e } ) ; throw e ; } if ( trace && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "serObjByte" ) ; return b ; }
Serialize an object to a byte array .