2010-05-19 14:17:06 -04:00
|
|
|
package com.fsck.k9.mail.filter;
|
2008-11-01 17:32:06 -04:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple OutputStream that does nothing but count how many bytes are written to it and
|
|
|
|
* makes that count available to callers.
|
|
|
|
*/
|
2011-02-06 17:09:48 -05:00
|
|
|
public class CountingOutputStream extends OutputStream {
|
2008-11-01 17:32:06 -04:00
|
|
|
private long mCount;
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public CountingOutputStream() {
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public long getCount() {
|
2008-11-01 17:32:06 -04:00
|
|
|
return mCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-02-06 17:09:48 -05:00
|
|
|
public void write(int oneByte) throws IOException {
|
2008-11-01 17:32:06 -04:00
|
|
|
mCount++;
|
|
|
|
}
|
2011-03-31 22:36:29 -04:00
|
|
|
|
|
|
|
@Override
|
2011-03-27 11:06:26 -04:00
|
|
|
public void write(byte b[], int offset, int len) throws IOException {
|
|
|
|
mCount += len;
|
|
|
|
}
|
2011-03-31 22:36:29 -04:00
|
|
|
|
|
|
|
@Override
|
2011-03-27 11:06:26 -04:00
|
|
|
public void write(byte[] b) throws IOException {
|
|
|
|
mCount += b.length;
|
|
|
|
}
|
2008-11-01 17:32:06 -04:00
|
|
|
}
|