james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Partial Parse Input Stream to load Mime message.
Date Thu, 04 Jul 2013 07:45:14 GMT
On Tue, 2013-07-02 at 23:06 -0700, Sudhir Movva wrote:
> Hi,
> I am trying to use mime4j to read from inputStream only the first body part
> into memory and stop reading (draining) from the input stream. I am using
> this in a servlet request context. So, to be short and precise,
> 
> 1. How can I partially read input stream
> 

You can simply stop reading from the stream or stop processing token
events.

> 2. How to stitch the body part after some modification back to the input
> stream and write the multipart to an output stream.
> 

I am not sure I understand the problem.

> 
> I used MultipartTokenStream to read from inputStream. I tried
> MimeTokenStream.stop() when the first T_END_BODYPART event is raised but
> observed that my input stream is empty(meaning even after calling the
> stop(), the stream was completely drained?? correct me if my observation is
> wrong)
> 

The stream does not get physically drained. It just gets marked as
truncated and any read operation on that stream always results in -1
bytes read (end of stream).

Oleg



Mime
View raw message