50 lines
970 B
Java
50 lines
970 B
Java
package org.kne.cloud.network.klalb;
|
|
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
public class OutputMetre extends OutputStream {
|
|
|
|
private OutputStream out;
|
|
private AtomicLong[] total;
|
|
public OutputMetre(OutputStream outputStream,AtomicLong ...v) {
|
|
this.out=outputStream;
|
|
this.total=v;
|
|
}
|
|
|
|
@Override
|
|
public void write(int b) throws IOException {
|
|
out.write(b);
|
|
for(AtomicLong x:total)
|
|
x.incrementAndGet();
|
|
}
|
|
|
|
@Override
|
|
public void write(byte[] b) throws IOException {
|
|
out.write(b);
|
|
for(AtomicLong x:total)
|
|
x.addAndGet(b.length);
|
|
}
|
|
|
|
@Override
|
|
public void write(byte[] b, int off, int len) throws IOException {
|
|
out.write(b, off, len);
|
|
for(AtomicLong x:total)
|
|
x.addAndGet(len);
|
|
}
|
|
|
|
@Override
|
|
public void flush() throws IOException {
|
|
out.flush();
|
|
}
|
|
|
|
@Override
|
|
public void close() throws IOException {
|
|
out.close();
|
|
}
|
|
|
|
|
|
|
|
}
|