Russ,

Each time that you call session.read(), you're going to get a new InputStream 
that starts at the beginning
of the FlowFile. So you can just call session.read() twice. For example:

final AtomicBoolean processContents = new AtomicBoolean(false);
session.read(flowFile, new InputStreamCallback() {
    public void process(InputStream in) {
       // read contents
      readContents.set( someValue );
    }
});

if (processContents.get()) {
    session.read(flowFile, new InputStreamCallback() {
        public void process(InputStream in) {
                // we now have a new InputStream that starts at the beginning 
of the FlowFile.
        }
    });
}


Does this answer your question sufficiently?

Thanks
-Mark


> On Sep 28, 2016, at 12:30 PM, Russell Bateman 
> <[email protected]> wrote:
> 
> This is more a Java question, I'm guessing. I have experimented 
> unconvincingly using Apache Commons I/O TeeInputStream, but let me back up...
> 
> I just need to, in some cases, consume the input stream:
> 
>   // under some condition, look into the flowfile contents to see if
>   something's there...
>   session.read( flowfile, new InputStreamCallback()
>   {
>      @Override
>   public void process( InputStream( in ) throws IOException
>      {
>        // read from in..
>      }
>   } );
> 
> 
> then, later (and always) consume it (so, sometimes a second time):
> 
>   session.read( flowfile, new InputStreamCallback()
>   {
>      @Override
>      public void process( InputStream( in ) throws IOException
>      {
>        // read from in..
>      }
>   } );
> 
> 
> Obviously, the content's gone at that point if I've already consumed it.
> 
> What should I do here instead? I don't have control over the close(), do I?
> 
> Thanks for any comment,
> 
> Russ

Reply via email to