package stream;

import java.io.IOException;
import java.io.OutputStream;

public class SafeOutputStream {

    private OutputStream underlyingStream;

    public SafeOutputStream(OutputStream underlyingStream) {
        this.underlyingStream = underlyingStream;
    }

    public void write(byte[] b) {
        try {
            underlyingStream.write(b);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    public void flush() {

        try {
            underlyingStream.flush();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

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

}