Package cx.ath.matthew.io
Class TeeOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- cx.ath.matthew.io.TeeOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class TeeOutputStream extends java.io.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(java.io.OutputStream os, java.io.File f)
Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.TeeOutputStream(java.io.OutputStream os, java.io.File f, boolean append)
Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.TeeOutputStream(java.io.OutputStream os, java.io.OutputStream tos)
Create a new TeeOutputStream on the given OutputStream and copy the stream to the other OuputStream.TeeOutputStream(java.io.OutputStream os, java.lang.String f)
Create a new TeeOutputStream on the given OutputStream and copy the stream to the given File.TeeOutputStream(java.io.OutputStream os, java.lang.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 void
close()
void
finalize()
void
flush()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
-
-
-
Constructor Detail
-
TeeOutputStream
public TeeOutputStream(java.io.OutputStream os, java.io.OutputStream tos) throws java.io.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:
java.io.IOException
-
TeeOutputStream
public TeeOutputStream(java.io.OutputStream os, java.io.File f, boolean append) throws java.io.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:
java.io.IOException
-
TeeOutputStream
public TeeOutputStream(java.io.OutputStream os, java.io.File f) throws java.io.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:
java.io.IOException
-
TeeOutputStream
public TeeOutputStream(java.io.OutputStream os, java.lang.String f, boolean append) throws java.io.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:
java.io.IOException
-
TeeOutputStream
public TeeOutputStream(java.io.OutputStream os, java.lang.String f) throws java.io.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:
java.io.IOException
-
-
Method Detail
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
finalize
public void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
-