org.eclipse.jgit.util.io
Class TeeInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.eclipse.jgit.util.io.TeeInputStream
All Implemented Interfaces:
Closeable

public class TeeInputStream
extends InputStream

Input stream that copies data read to another output stream. This stream is primarily useful with a TemporaryBuffer, where any data read or skipped by the caller is also duplicated into the temporary buffer. Later the temporary buffer can then be used instead of the original source stream. During close this stream copies any remaining data from the source stream into the destination stream.


Constructor Summary
TeeInputStream(InputStream src, OutputStream dst)
          Initialize a tee input stream.
 
Method Summary
 void close()
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 long skip(long cnt)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TeeInputStream

public TeeInputStream(InputStream src,
                      OutputStream dst)
Initialize a tee input stream.

Parameters:
src - source stream to consume.
dst - destination to copy the source to as it is consumed. Typically this is a TemporaryBuffer.
Method Detail

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

skip

public long skip(long cnt)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException


Copyright © 2012. All Rights Reserved.