package stream;

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

public class SafeInputStream {

    private InputStream underlyingStream;

    public SafeInputStream(InputStream underlyingStream) {
        this.underlyingStream = underlyingStream;
    }

    public int read() {
        try {
            return underlyingStream.read();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    public void close() {
        try {
            underlyingStream.close();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

}