Class FilterWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Abstract class for writing filtered character streams.
The abstract class
FilterWriter itself
provides default methods that pass all requests to the
contained stream. Subclasses of FilterWriter
should override some of these methods and may also
provide additional methods and fields.- Since:
- 1.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods declared in class Writer
append, append, append, nullWriter, write, writeModifier and TypeMethodDescriptionappend(char c) Appends the specified character to this writer.append(CharSequence csq) Appends the specified character sequence to this writer.append(CharSequence csq, int start, int end) Appends a subsequence of the specified character sequence to this writer.static WriterReturns a newWriterwhich discards all characters.voidwrite(char[] cbuf) Writes an array of characters.voidWrites a string.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
out
The underlying character-output stream.
-
-
Constructor Details
-
FilterWriter
Create a new filtered writer.- Parameters:
out- a Writer object to provide the underlying stream.- Throws:
NullPointerException- ifoutisnull
-
-
Method Details
-
write
Writes a single character.- Overrides:
writein classWriter- Parameters:
c- int specifying a character to be written- Throws:
IOException- If an I/O error occurs
-
write
Writes a portion of an array of characters.- Specified by:
writein classWriter- Parameters:
cbuf- Buffer of characters to be writtenoff- Offset from which to start reading characterslen- Number of characters to be written- Throws:
IndexOutOfBoundsException- If the values of theoffandlenparameters cause the corresponding method of the underlyingWriterto throw anIndexOutOfBoundsExceptionIOException- If an I/O error occurs
-
write
Writes a portion of a string.- Overrides:
writein classWriter- Parameters:
str- String to be writtenoff- Offset from which to start reading characterslen- Number of characters to be written- Throws:
IndexOutOfBoundsException- If the values of theoffandlenparameters cause the corresponding method of the underlyingWriterto throw anIndexOutOfBoundsExceptionIOException- If an I/O error occurs
-
flush
Flushes the stream.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException- If an I/O error occurs
-
close
Description copied from class:WriterCloses the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException- If an I/O error occurs
-