mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
init2
This commit is contained in:
37
src/main/java/arcane/util/MultiplexOutputStream.java
Normal file
37
src/main/java/arcane/util/MultiplexOutputStream.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package arcane.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* An OutputStream that writes to multiple other OutputStreams.
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MultiplexOutputStream extends OutputStream {
|
||||
private final OutputStream[] streams;
|
||||
|
||||
/**
|
||||
* <p>Constructor for MultiplexOutputStream.</p>
|
||||
*
|
||||
* @param streams a {@link java.io.OutputStream} object.
|
||||
*/
|
||||
public MultiplexOutputStream(OutputStream... streams) {
|
||||
super();
|
||||
if (streams == null) throw new IllegalArgumentException("streams cannot be null.");
|
||||
this.streams = streams;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void write(int b) throws IOException {
|
||||
for (int i = 0; i < streams.length; i++)
|
||||
streams[i].write(b);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
for (int i = 0; i < streams.length; i++)
|
||||
streams[i].write(b, off, len);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user