All Downloads are FREE. Search and download functionalities are using the official Maven repository.

asset.pipeline.utils.MultiOutputStream.groovy Maven / Gradle / Ivy

Go to download

JVM Asset Pipeline library for serving static web assets, bundling, minifying, and extensibility for transpiling.

There is a newer version: 6.0.1
Show 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