private void resetInputStreams ( ) throws IOException , MessagingException { for ( int ix = 0 ; ix < this . getCount ( ) ; ix ++ ) { BodyPart part = this . getBodyPart ( ix ) ; if ( part . getContent ( ) instanceof MimeMultipart ) { MimeMultipart subContent = ( MimeMultipart ) part . getContent ( ) ; for ( int jx = 0 ; jx < subContent . getCount ( ) ; jx ++ ) { BodyPart subPart = subContent . getBodyPart ( jx ) ; if ( subPart . getContent ( ) instanceof ByteArrayInputStream ) { ( ( ByteArrayInputStream ) subPart . getContent ( ) ) . reset ( ) ; } } } } }
reset all input streams to allow redirect filter to write the output twice