org.apache.servicemix.jbi.audit.file
Class TeeInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.apache.servicemix.jbi.audit.file.TeeInputStream
All Implemented Interfaces:
Closeable

public class TeeInputStream
extends FilterInputStream

FilterInputStream implementation that sends a copy of all data being processed to the specified OutputStream.

Since:
3.2
Author:
Gert Vanthienen (gertv)

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
TeeInputStream(InputStream is, OutputStream os)
          Create a new TeeInputStream
 
Method Summary
 void close()
          Close the underlying InputStream.
 int read()
          Reads a single byte from the underlying InputStream.
 int read(byte[] bytes, int offset, int length)
          Read a block of bytes from the underlying InputStream.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TeeInputStream

public TeeInputStream(InputStream is,
                      OutputStream os)
Create a new TeeInputStream

Parameters:
is - the InputStream to read from
os - the OuputStream to copy data to
Method Detail

read

public int read()
         throws IOException
Reads a single byte from the underlying InputStream. In addition, it also write the same byte to the OutputStream.

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] bytes,
                int offset,
                int length)
         throws IOException
Read a block of bytes from the underlying InputStream. In addition, write the same data to the OutputStream.

Overrides:
read in class FilterInputStream
Throws:
IOException

close

public void close()
           throws IOException
Close the underlying InputStream. Also, flush and close the underlying OutputStream.

Specified by:
close in interface Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException


Copyright © 2005-2010 The Apache Software Foundation. All Rights Reserved.