java.lang.Object
java.io.Writer
com.aoapps.io.buffer.BufferWriter
com.aoapps.io.buffer.AutoTempFileWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Writes to an initial buffer then switches to a temp file when the threshold is reached.
This class is not thread safe.
- Author:
- AO Industries, Inc.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
A reasonable default temp file threshold, currently 4 MB. -
Constructor Summary
ConstructorDescriptionAutoTempFileWriter
(BufferWriter initialBuffer, TempFileContext tempFileContext) Uses the default temp file threshold.AutoTempFileWriter
(BufferWriter initialBuffer, TempFileContext tempFileContext, long tempFileThreshold) -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) void
close()
void
flush()
long
Gets the number of characters in this buffer.Gets the result from this buffer.toString()
Gets a short message (like type and length).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
-
Field Details
-
DEFAULT_TEMP_FILE_THRESHOLD
public static final long DEFAULT_TEMP_FILE_THRESHOLDA reasonable default temp file threshold, currently 4 MB.- See Also:
-
-
Constructor Details
-
AutoTempFileWriter
public AutoTempFileWriter(BufferWriter initialBuffer, TempFileContext tempFileContext, long tempFileThreshold) -
AutoTempFileWriter
Uses the default temp file threshold.
-
-
Method Details
-
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
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
getLength
Description copied from class:BufferWriter
Gets the number of characters in this buffer. Once closed, this length will not be modified.- Specified by:
getLength
in classBufferWriter
- Throws:
IOException
-
toString
Description copied from class:BufferWriter
Gets a short message (like type and length).- Specified by:
toString
in classBufferWriter
- See Also:
-
getResult
Description copied from class:BufferWriter
Gets the result from this buffer. The buffer must be closed.Note: Although the
BufferWriter
are generally not thread-safe, theBufferResult
is thread-safe. It is expected to commonly create a buffer on one thread, but the be able to safely share the result among many threads.- Specified by:
getResult
in classBufferWriter
- Throws:
IllegalStateException
- if not closedIOException
-