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

org.springframework.content.commons.io.ObservableInputStream Maven / Gradle / Ivy

There is a newer version: 3.0.15
Show newest version
package org.springframework.content.commons.io;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ObservableInputStream extends InputStream {

    private final InputStream is;
    private final CloseableObserver observer;

    public ObservableInputStream(InputStream is, CloseableObserver observer) {
        this.is = is;
        this.observer = observer;
    }

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

    @Override
    public int read() throws IOException {
        return this.is.read();
    }

    @Override
    public void close() throws IOException {
        super.close();
        this.observer.closed();
    }

    public List getObservers() {
        return Arrays.asList(new CloseableObserver[]{observer});
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy