private void readStreamArgument ( XMLEventReader reader , ConsumerJournalEntry journalEntry , String name ) throws XMLStreamException , JournalException { try { File tempFile = JournalHelper . createTempFile ( ) ; DecodingBase64OutputStream decoder = new DecodingBase64OutputStream ( new FileOutputStream ( tempFile ) ) ; while ( true ) { XMLEvent event = reader . nextEvent ( ) ; if ( event . isCharacters ( ) ) { decoder . write ( event . asCharacters ( ) . getData ( ) ) ; } else if ( isEndTagEvent ( event , QNAME_TAG_ARGUMENT ) ) { break ; } else { throw getUnexpectedEventInArgumentException ( name , ARGUMENT_TYPE_STREAM , journalEntry . getMethodName ( ) , event ) ; } } decoder . close ( ) ; journalEntry . addArgument ( name , tempFile ) ; } catch ( IOException e ) { throw new JournalException ( "failed to write stream argument to temp file" , e ) ; } }
An InputStream argument appears as a Base64 - encoded String . It must be decoded and written to a temp file so it can be presented to the management method as an InputStream again .