public class NoCloseWriter extends java.io.Writer implements NoCloseStream
This class is designed to wrap a normal writer so that it can be passed to methods that write to it and may erroneously close it. This class is a workaround when the method cannot be modified because it is in a library.
| Modifier and Type | Field and Description |
|---|---|
protected java.io.Writer |
out
The writer that is being protected.
|
| Constructor and Description |
|---|
NoCloseWriter(java.io.Writer out)
Protect a new writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Has no effect.
|
void |
flush() |
void |
reallyClose()
Actually closes this stream and releases any system
resources associated with the stream, as opposed to
the close() method, which does nothing.
|
void |
write(char[] cbuf) |
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int c) |
void |
write(java.lang.String str) |
void |
write(java.lang.String str,
int off,
int len) |
protected java.io.Writer out
public NoCloseWriter(java.io.Writer out)
out - The writer that is being protected.public void write(int c)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void write(char[] cbuf)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void write(java.lang.String str)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOExceptionreallyClose()public void reallyClose()
throws java.io.IOException
reallyClose in interface NoCloseStreamjava.io.IOException - if an I/O error occurs.Copyright (c) 2001-2020 by Stephen Ostermiller