cx.ath.matthew.io
Class TeeOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by cx.ath.matthew.io.TeeOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class TeeOutputStream
extends FilterOutputStream

Class to copy a stream to another stream or file as it is being sent through a stream pipe E.g.

    PrintWriter r = new PrintWriter(new TeeOutputStream(new FileOutputStream("file"), new File("otherfile")));
 


Constructor Summary
TeeOutputStream(OutputStream os, File f)
          Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.
TeeOutputStream(OutputStream os, File f, boolean append)
          Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.
TeeOutputStream(OutputStream os, OutputStream tos)
          Create a new TeeOutputStream on the given OutputStream and copy the stream to the other OuputStream.
TeeOutputStream(OutputStream os, String f)
          Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.
TeeOutputStream(OutputStream os, String f, boolean append)
          Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.
 
Method Summary
 void close()
           
 void finalize()
           
 void flush()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TeeOutputStream

public TeeOutputStream(OutputStream os,
                       OutputStream tos)
                throws IOException
Create a new TeeOutputStream on the given OutputStream and copy the stream to the other OuputStream.

Parameters:
os - Writes to this OutputStream
tos - Write to this OutputStream
Throws:
IOException

TeeOutputStream

public TeeOutputStream(OutputStream os,
                       File f,
                       boolean append)
                throws IOException
Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.

Parameters:
os - Writes to this OutputStream
f - Write to this File
append - Append to file not overwrite
Throws:
IOException

TeeOutputStream

public TeeOutputStream(OutputStream os,
                       File f)
                throws IOException
Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.

Parameters:
os - Writes to this OutputStream
f - Write to this File
Throws:
IOException

TeeOutputStream

public TeeOutputStream(OutputStream os,
                       String f,
                       boolean append)
                throws IOException
Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.

Parameters:
os - Writes to this OutputStream
f - Write to this File
append - Append to file not overwrite
Throws:
IOException

TeeOutputStream

public TeeOutputStream(OutputStream os,
                       String f)
                throws IOException
Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.

Parameters:
os - Writes to this OutputStream
f - Write to this File
Throws:
IOException
Method Detail

close

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

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class FilterOutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

finalize

public void finalize()
Overrides:
finalize in class Object