public abstract class SubstitutingWriter extends FilterWriter
An SubstitutingWriter is a FilterWriter that replaces each character in the output stream with the String obtained by calling the abstract method substitute on the characters.
Characters for which substitute returns null are output verbatim.
The implementation is fairly efficient in the number of calls to the various out.write methods.
out| Constructor and Description |
|---|
SubstitutingWriter(Writer out) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract String |
substitute(char c)
What should be printed instead of character
c?
This method is always called synchronized on out. |
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters, applying the substitution.
|
void |
write(int c)
Write a single character, applying the substitution.
|
void |
write(String str,
int off,
int len)
Write a portion of a string, applying the substitution.
|
protected void |
writeReplacement(String replacement) |
close, flushpublic SubstitutingWriter(Writer out)
protected abstract String substitute(char c)
c?
This method is always called synchronized on out.
Changes to the substitution function should therefore also be synchronized on out.c - the charactercprotected void writeReplacement(String replacement) throws IOException
IOExceptionpublic void write(int c)
throws IOException
write in class FilterWriterIOException - If an I/O error occurspublic void write(char[] cbuf,
int off,
int len)
throws IOException
write in class FilterWritercbuf - Buffer of characters to be writtenoff - Offset from which to start reading characterslen - Number of characters to be writtenIOException - If an I/O error occurspublic void write(String str, int off, int len) throws IOException
write in class FilterWriterstr - String to be writtenoff - Offset from which to start reading characterslen - Number of characters to be writtenIOException - If an I/O error occursCopyright © 2002–2018 CoreMedia AG. All rights reserved.