
aQute.lib.redirect.Tee Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biz.aQute.bndlib Show documentation
Show all versions of biz.aQute.bndlib Show documentation
bndlib: A Swiss Army Knife for OSGi
The newest version!
package aQute.lib.redirect;
import java.io.IOException;
import java.io.OutputStream;
import aQute.lib.io.IO;
public class Tee extends OutputStream {
final OutputStream[] out;
final Thread thread;
public Tee(OutputStream... out) {
this(null, out);
}
public Tee(Thread thread, OutputStream... out) {
this.thread = thread;
this.out = out;
}
@Override
public void write(int b) throws IOException {
if (thread == null || Thread.currentThread() == thread)
for (OutputStream o : out) {
o.write(b);
}
}
@Override
public void write(byte[] b) throws IOException {
if (thread == null || Thread.currentThread() == thread)
for (OutputStream o : out) {
o.write(b);
}
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
if (thread == null || Thread.currentThread() == thread)
for (OutputStream o : out) {
o.write(b, off, len);
}
}
@Override
public void close() throws IOException {
IO.closeAll((Object[]) out);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy