|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream de.jstacs.utils.SafeOutputStream
public class SafeOutputStream
This class is for any output. For example:
new SafeOutputStream( null )
).
new SafeOutputStream( System.out )
).
new SafeOutputStream( new FileOutputStream( ... ) )
).
finalize
method.
Field Summary | |
---|---|
static OutputStream |
DEFAULT_STREAM
This stream can be used as default stream. |
Constructor Summary | |
---|---|
SafeOutputStream(OutputStream ostream)
Creates a new SafeOutputStream . |
Method Summary | |
---|---|
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(String s)
Writes a String . |
void |
writeln()
Writes a line break. |
void |
writeln(String s)
Writes a String and a line break. |
Methods inherited from class java.io.OutputStream |
---|
write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final OutputStream DEFAULT_STREAM
Constructor Detail |
---|
public SafeOutputStream(OutputStream ostream)
SafeOutputStream
.
ostream
- the internal used OutputStream
Method Detail |
---|
public static SafeOutputStream getSafeOutputStream(OutputStream out)
SafeOutputStream
for a given OutputStream
.
out
- the OutputStream
SafeOutputStream
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 Closeable
close
in class OutputStream
IOException
- if something went wrong in closing the output streampublic boolean doesNothing()
true
if the internal OutputStream
is
null
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public OutputStream getOutputStream()
OutputStream
.
OutputStream
public void writeln() throws IOException
IOException
- if something went wrongwrite(int)
public void writeln(String s) throws IOException
String
and a line break.
s
- the String
to be written
IOException
- if something went wrongwrite(int)
public void write(String s) throws IOException
String
.
s
- the String
to be written
IOException
- if something went wrongwrite(int)
public void write(int b) throws IOException
write
in class OutputStream
IOException
protected void finalize() throws IOException
finalize
in class Object
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |