java.lang.Object
java.io.Writer
com.aoapps.hodgepodge.io.FindReplaceWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Replaces strings while writing.
This class is not thread safe and requires external synchronization if used by more than one thread.
This is a simple implementation that forces all writes to be one character at a time.
It is recommended to use along with BufferedWriter
when used in a performance-sensitive application.
- Author:
- AO Industries, Inc.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionFindReplaceWriter
(Writer out, char[] find, char[] replace) FindReplaceWriter
(Writer out, String find, String replace) -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) void
close()
void
flush()
void
write
(char[] cbuf, int off, int len) void
write
(int c) void
Methods inherited from class java.io.Writer
nullWriter, write, write
-
Constructor Details
-
FindReplaceWriter
- See Also:
-
FindReplaceWriter
- Parameters:
out
- The writer that will receive the converted stream.find
- The text to find. No defensive copy is made. Do not modify after giving to this writer.replace
- The text to replace. No defensive copy is made. Do not modify after giving to this writer.
-
-
Method Details
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-