Package com.aoindustries.io.buffer
Class SegmentedWriter
- java.lang.Object
-
- java.io.Writer
-
- com.aoindustries.io.buffer.BufferWriter
-
- com.aoindustries.io.buffer.SegmentedWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class SegmentedWriter extends BufferWriter
Buffers all writes in segments. This is to hold references to strings instead of copying all the characters. This class is not thread safe. Future: If writing to another segmented buffer, the segments could be shared between the two instances. (or arraycopy instead of writing each)- Author:
- AO Industries, Inc.
-
-
Constructor Summary
Constructors Constructor Description SegmentedWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SegmentedWriterappend(char c)SegmentedWriterappend(CharSequence csq)SegmentedWriterappend(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)voidwrite(char[] cbuf, int off, int len)voidwrite(int c)voidwrite(String str)voidwrite(String str, int off, int len)
-
-
-
Method Detail
-
write
public void write(int c) throws ClosedChannelException- Overrides:
writein classWriter- Throws:
ClosedChannelException
-
write
public void write(char[] cbuf) throws ClosedChannelException- Overrides:
writein classWriter- Throws:
ClosedChannelException
-
write
public void write(char[] cbuf, int off, int len) throws ClosedChannelException- Specified by:
writein classWriter- Throws:
ClosedChannelException
-
write
public void write(String str) throws ClosedChannelException
- Overrides:
writein classWriter- Throws:
ClosedChannelException
-
write
public void write(String str, int off, int len) throws ClosedChannelException
- Overrides:
writein classWriter- Throws:
ClosedChannelException
-
append
public SegmentedWriter append(CharSequence csq) throws ClosedChannelException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
ClosedChannelException
-
append
public SegmentedWriter append(CharSequence csq, int start, int end) throws ClosedChannelException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
ClosedChannelException
-
append
public SegmentedWriter append(char c) throws ClosedChannelException
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
ClosedChannelException
-
flush
public void flush()
-
close
public void close()
-
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
-
-