package cs522.elind.io; import java.io.*; public class MonitorOutputStream extends OutputStream { OutputStream monitor = null; long totalWritten = 0; /** Creates a new instance of MonitorOutputStream */ public MonitorOutputStream(OutputStream out) { monitor = out; } public long bytesWritten() { return totalWritten; } public void write(int b) throws IOException { monitor.write(b); int written = b & 255; totalWritten += written; } public void write(byte[] b) throws IOException { monitor.write(b); int written = b.length; totalWritten += written; } public void write(byte[] b, int off, int len) throws IOException { monitor.write(b, off, len); int written = len; totalWritten += written; } public void flush() throws IOException { monitor.flush(); } public void close() throws IOException { monitor.close(); } }