Added CountingOutputStream class

This commit is contained in:
hasher 2020-07-15 16:21:20 +05:30
Родитель ded2aaaadb
Коммит 4bdaa588ca
1 изменённых файлов: 37 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,37 @@
package com.microsoft.azure.kusto.kafka.connect.sink;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class CountingOutputStream extends FilterOutputStream {
public long numBytes = 0;
public OutputStream outputStream;
public CountingOutputStream(OutputStream out) {
super(out);
this.outputStream = out;
}
@Override
public void write(int b) throws IOException {
out.write(b);
this.numBytes++;
}
@Override
public void write(byte[] b) throws IOException {
out.write(b);
this.numBytes += b.length;
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
this.numBytes += len;
}
public OutputStream getOutputStream() {
return outputStream;
}
}