1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.plugin
.util
;
12 import java
.io
.IOException
;
13 import java
.io
.OutputStream
;
16 * This is an output stream that is guarded by being closed.
20 public final class GuardedOutputStream
23 /** The true output stream. */
24 protected final OutputStream out
;
26 /** Is this closed? */
27 volatile boolean _closed
;
30 * Initializes the guarded stream.
32 * @param __out The output stream.
33 * @throws NullPointerException On null arguments.
36 public GuardedOutputStream(OutputStream __out
)
37 throws NullPointerException
40 throw new NullPointerException("NARG");
55 // Make sure everything is written before closing
76 throw new IOException("Stream is closed.");
86 public void write(int __b
)
90 throw new IOException("Stream is closed.");
100 public void write(byte[] __b
)
104 throw new IOException("Stream is closed.");
114 public void write(byte[] __b
, int __o
, int __l
)
118 throw new IOException("Stream is closed.");
120 this.out
.write(__b
, __o
, __l
);