java.lang.Object
java.io.Writer
com.aoapps.lang.io.AppendableWriter
- All Implemented Interfaces:
NoClose
,Closeable
,Flushable
,Appendable
,AutoCloseable
Writer that writes to an underlying
Appendable
.
This is not necessarily the absolute fastest way to get things done (at least
when a char[]
has to be wrapped in a Segment
), but can help
bridge the gap between APIs based on Writer
and Appendable
.- Author:
- AO Industries, Inc.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) void
close()
Calls to close are ignored whenNoClose.isNoClose()
, otherwise some action might be taken which means close calls to this object may not be skipped or assumed to be ignored.void
flush()
getOut()
Gets the wrapped appendable.boolean
Determines if calls toNoClose.close()
will be ignored.static Writer
wrap
(Appendable out) Wraps the givenAppendable
if it is not already aWriter
.void
write
(char[] cbuf) void
write
(char[] cbuf, int off, int len) void
write
(int c) void
void
Methods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
AppendableWriter
-
-
Method Details
-
wrap
Wraps the givenAppendable
if it is not already aWriter
.- Returns:
- The given out, if it is already a
Writer
, otherwise anAppendableWriter
wrapping out.
-
getOut
Gets the wrapped appendable. -
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
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
-
isNoClose
public boolean isNoClose()Description copied from interface:NoClose
Determines if calls toNoClose.close()
will be ignored. This value must not change over time; it may be queried once, repeatedly, or never. -
close
Description copied from interface:NoClose
Calls to close are ignored whenNoClose.isNoClose()
, otherwise some action might be taken which means close calls to this object may not be skipped or assumed to be ignored.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceNoClose
- Specified by:
close
in classWriter
- Throws:
IOException
-