Package com.aoindustries.io.buffer
Class CharArrayBufferWriter
- java.lang.Object
-
- java.io.Writer
-
- com.aoindustries.io.buffer.BufferWriter
-
- com.aoindustries.io.buffer.CharArrayBufferWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class CharArrayBufferWriter extends BufferWriter
Writes to a set of internally managed buffers. When possible, the buffers are reused.Maximum length is 2 ^ 30 characters (about 1 billion). When this limit is insufficient, consider using along with
AutoTempFileWriter.This class is not thread safe.
- Author:
- AO Industries, Inc.
- See Also:
for a possibly more efficient implementation.
-
-
Constructor Summary
Constructors Constructor Description CharArrayBufferWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharArrayBufferWriterappend(char c)CharArrayBufferWriterappend(CharSequence csq)CharArrayBufferWriterappend(CharSequence csq, int start, int end)voidclose()voidflush()longgetLength()Gets the number of characters in this buffer.BufferResultgetResult()Gets the result from this buffer.StringtoString()Gets a short message (like type and length).voidwrite(char[] cbuf, int off, int len)voidwrite(int c)voidwrite(String str, int off, int len)
-
-
-
Method Detail
-
write
public void write(int c) 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, int off, int len) throws IOException
- Overrides:
writein classWriter- Throws:
IOException
-
append
public CharArrayBufferWriter append(CharSequence csq) throws IOException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
append
public CharArrayBufferWriter append(CharSequence csq, int start, int end) throws IOException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
append
public CharArrayBufferWriter 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
-
getLength
public long getLength()
Description copied from class:BufferWriterGets the number of characters in this buffer. Once closed, this length will not be modified.- Specified by:
getLengthin classBufferWriter
-
toString
public String toString()
Description copied from class:BufferWriterGets a short message (like type and length).- Specified by:
toStringin classBufferWriter- See Also:
To get access to the buffered content.
-
getResult
public BufferResult getResult() throws IllegalStateException
Description copied from class:BufferWriterGets the result from this buffer. The buffer must be closed.- Specified by:
getResultin classBufferWriter- Throws:
IllegalStateException- if not closed
-
-