com.rt.storage.api.client.util.ByteCountingOutputStream Maven / Gradle / Ivy
package com.rt.storage.api.client.util;
import java.io.IOException;
import java.io.OutputStream;
/**
* Output stream that throws away any content and only retains the count of bytes written to the
* stream.
*
* @author Yaniv Inbar
*/
final class ByteCountingOutputStream extends OutputStream {
/** Number of bytes written. */
long count;
@Override
public void write(byte[] b, int off, int len) throws IOException {
count += len;
}
@Override
public void write(int b) throws IOException {
count++;
}
}