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

org.tarantool.CountInputStreamImpl Maven / Gradle / Ivy

There is a newer version: 1.9.4
Show newest version
package org.tarantool;

import java.io.IOException;
import java.io.InputStream;

public class CountInputStreamImpl extends CountInputStream {

    protected InputStream is;
    protected long bytesRead;

    public CountInputStreamImpl(InputStream is) throws IOException {
        this.is = is;
    }

    @Override
    public int read() throws IOException {
        bytesRead++;
        return 0XFF & is.read();
    }

    @Override
    public int read(byte[] b, final int off, final int len) throws IOException {
        int read = is.read(b, off, len);
        bytesRead += read;
        return read;
    }

    @Override
    public void close() throws IOException {
        is.close();
    }

    public long getBytesRead() {
        return bytesRead;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy