public class SafeOutputStream extends OutputStream
new SafeOutputStream( null )).
new SafeOutputStream( System.out )).
new SafeOutputStream( new FileOutputStream( ... ) )).
finalize method.| Modifier and Type | Field and Description |
|---|---|
static OutputStream |
DEFAULT_STREAM
This stream can be used as default stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
SafeOutputStream by closing the OutputStream
this stream was constructed of. |
boolean |
doesNothing()
Indicates whether the instance is doing something or not.
|
protected void |
finalize() |
void |
flush() |
OutputStream |
getOutputStream()
Returns the internal used
OutputStream. |
static SafeOutputStream |
getSafeOutputStream(OutputStream out)
This method returns an instance of
SafeOutputStream for a given OutputStream. |
void |
write(int b) |
void |
write(Object s)
Writes an
Object using Object.toString(). |
void |
writeln()
Writes a line break.
|
void |
writeln(Object s)
Writes an
Object and a line break. |
write, writepublic static final OutputStream DEFAULT_STREAM
public static SafeOutputStream getSafeOutputStream(OutputStream out)
SafeOutputStream for a given OutputStream.out - the OutputStreamSafeOutputStream for a given OutputStream.public void close()
throws IOException
SafeOutputStream by closing the OutputStream
this stream was constructed of. If this SafeOutputStream was
constructed using System.out this OutputStream will
be closed. No outputs via System.out will be possible any
more.close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - if something went wrong in closing the output streampublic boolean doesNothing()
true if the internal OutputStream is
nullpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic OutputStream getOutputStream()
OutputStream.OutputStreampublic void writeln()
throws IOException
IOException - if something went wrongwrite(int)public void writeln(Object s) throws IOException
Object and a line break.s - the Object to be writtenIOException - if something went wrongwrite(int),
Object.toString()public void write(Object s) throws IOException
Object using Object.toString().s - the Object to be writtenIOException - if something went wrongwrite(int)public void write(int b)
throws IOException
write in class OutputStreamIOExceptionprotected void finalize()
throws IOException
finalize in class ObjectIOException