import java.io.IOException;
import java.io.OutputStream;
/**
* Output stream that counts bytes written to it (but discards them).
*
* @author Jonathan Locke
*/
public final class ByteCountingOutputStream extends OutputStream
{
private long size;
/**
* @see java.io.OutputStream#write(int)
*/
public void write(int b) throws IOException
{
size++;
}
/**
* @see java.io.OutputStream#write(byte[], int, int)
*/
public void write(byte b[], int off, int len) throws IOException
{
size += len;
}
/**
* @return Number of bytes written to this stream
*/
public long size()
{
return size;
}
}