Package cx.ath.matthew.io
Class TeeOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- cx.ath.matthew.io.TeeOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
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
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidfinalize()voidflush()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
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 OutputStreamtos- 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 OutputStreamf- Write to this Fileappend- 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 OutputStreamf- 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 OutputStreamf- Write to this Fileappend- 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 OutputStreamf- Write to this File- Throws:
IOException
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterOutputStream- Throws:
IOException
-
write
public void write(int b) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
public void write(byte[] b) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
-