asset.pipeline.utils.MultiOutputStream.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of asset-pipeline-core Show documentation
Show all versions of asset-pipeline-core Show documentation
JVM Asset Pipeline library for serving static web assets, bundling, minifying, and extensibility for transpiling.
The newest version!
package asset.pipeline.utils
import groovy.transform.CompileStatic
/**
* An OutputStream capable of writing to a collection of output streams underneath simultaneously
*
* @author David Estes
*/
@CompileStatic
public class MultiOutputStream extends OutputStream{
private final Collection streams;
/**
* Constructor method for creating the input Stream
* @param streams a list or collection of output streams
*/
public MultiOutputStream(Collection streams) {
if (streams == null)
throw new NullPointerException();
this.streams = streams
}
@Override
public void write(int b) throws IOException {
streams.each { OutputStream stream ->
stream.write(b)
}
}
@Override
public void write(byte[] b) throws IOException {
streams.each { OutputStream stream ->
stream.write(b)
}
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
streams.each { OutputStream stream ->
stream.write(b, off, len)
}
}
@Override
public void flush() throws IOException {
streams.each { OutputStream stream ->
stream.flush()
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy