- java.lang.Object
-
- java.io.Writer
-
- com.aoapps.lang.io.AppendableWriter
-
- All Implemented Interfaces:
NoClose,Closeable,Flushable,Appendable,AutoCloseable
public class AppendableWriter extends Writer implements NoClose
Writer that writes to an underlyingAppendable. This is not necessarily the absolute fastest way to get things done (at least when achar[]has to be wrapped in aSegment), but can help bridge the gap between APIs based onWriterandAppendable.- Author:
- AO Industries, Inc.
-
-
Constructor Summary
Constructors Constructor Description AppendableWriter(Appendable out)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AppendableWriterappend(char c)AppendableWriterappend(CharSequence csq)AppendableWriterappend(CharSequence csq, int start, int end)voidclose()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.voidflush()AppendablegetOut()Gets the wrapped appendable.booleanisNoClose()Determines if calls toNoClose.close()will be ignored.static Writerwrap(Appendable out)Wraps the givenAppendableif it is not already aWriter.voidwrite(char[] cbuf)voidwrite(char[] cbuf, int off, int len)voidwrite(int c)voidwrite(String str)voidwrite(String str, int off, int len)-
Methods inherited from class java.io.Writer
nullWriter
-
-
-
-
Constructor Detail
-
AppendableWriter
public AppendableWriter(Appendable out)
-
-
Method Detail
-
wrap
public static Writer wrap(Appendable out)
Wraps the givenAppendableif it is not already aWriter.- Returns:
- The given out, if it is already a
Writer, otherwise anAppendableWriterwrapping out.
-
getOut
public Appendable getOut()
Gets the wrapped appendable.
-
write
public void write(int c) throws IOException- Overrides:
writein classWriter- Throws:
IOException
-
write
public void write(char[] cbuf) throws IOException- Overrides:
writein classWriter- Throws:
IOException
-
write
public void write(char[] cbuf, int off, int len) throws IOException- Specified by:
writein classWriter- Throws:
IOException
-
write
public void write(String str) throws IOException
- Overrides:
writein classWriter- Throws:
IOException
-
write
public void write(String str, int off, int len) throws IOException
- Overrides:
writein classWriter- Throws:
IOException
-
append
public AppendableWriter append(CharSequence csq) throws IOException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
append
public AppendableWriter append(CharSequence csq, int start, int end) throws IOException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
append
public AppendableWriter append(char c) throws IOException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
isNoClose
public boolean isNoClose()
Description copied from interface:NoCloseDetermines if calls toNoClose.close()will be ignored. This value must not change over time; it may be queried once, repeatedly, or never.
-
close
public void close() throws IOExceptionDescription copied from interface:NoCloseCalls 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceNoClose- Specified by:
closein classWriter- Throws:
IOException
-
-