closed = true;
if (closed) throw new IOException("Write to closed stream");
if (data == null) throw new NullPointerException("data is null"); if (closed) throw new IOException("Write to closed stream");