
net.yapbam.data.xml.task.PipeTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yapbam-commons Show documentation
Show all versions of yapbam-commons Show documentation
Commons Yapbam classes used by desktop and Android versions.
package net.yapbam.data.xml.task;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.Callable;
import net.yapbam.util.StreamUtils;
/** A task that reads the content of an input stream and outputs it to an output stream.
*/
public class PipeTask implements Callable {
private InputStream in;
private OutputStream out;
/** Constructor.
* @param in The input stream (will be closed by the task)
* @param out The output stream (will remain opened)
*/
public PipeTask (InputStream in, OutputStream out) {
this.in = in;
this.out = out;
}
@Override
public Void call() throws IOException {
try {
byte[] buffer = new byte[FilterTask.BUFFER_SIZE];
StreamUtils.copy(in, out, buffer);
return null;
} finally {
in.close();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy