- java.lang.Object
-
- java.io.Writer
-
- com.aoapps.lang.io.AppendableWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class AppendableWriter extends Writer
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()voidflush()AppendablegetOut()Gets the wrapped appendable.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
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
-