All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.akurilov.commons.io.ByteCountOutputStream Maven / Gradle / Ivy

package com.github.akurilov.commons.io;

import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.atomic.LongAdder;

public class ByteCountOutputStream
extends OutputStream {

	protected final LongAdder byteCount = new LongAdder();

	public final long byteCount() {
		return byteCount.sum();
	}

	@Override
	public void write(final int b)
	throws IOException {
		byteCount.increment();
	}

	@Override
	public void write(final byte buff[], final int off, final int len)
	throws IOException {
		byteCount.add(len);
	}

	@Override
	public void write(final byte buff[])
	throws IOException {
		byteCount.add(buff.length);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy