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

org.browsermob.proxy.util.ClonedInputStream Maven / Gradle / Ivy

There is a newer version: 2.0-beta-7
Show newest version
package org.browsermob.proxy.util;

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

public class ClonedInputStream extends InputStream {
    private InputStream is;
    private ByteArrayOutputStream os = new ByteArrayOutputStream();

    public ClonedInputStream(InputStream is) {
        this.is = is;
    }

    public int read() throws IOException {
        int resp = is.read();
        os.write(resp);

        return resp;
    }

    public int read(byte[] b) throws IOException {
        int resp = is.read(b);
        os.write(b);

        return resp;
    }

    public int read(byte[] b, int off, int len) throws IOException {
        int resp = is.read(b, off, len);
        os.write(b, off, len);

        return resp;
    }

    public long skip(long n) throws IOException {
        return is.skip(n);
    }

    public int available() throws IOException {
        return is.available();
    }

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

    public void mark(int readlimit) {
        is.mark(readlimit);
    }

    public void reset() throws IOException {
        os.reset();
        is.reset();
    }

    public boolean markSupported() {
        return is.markSupported();
    }

    public ByteArrayOutputStream getOutput() {
        return os;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy