public class TransactionAwareBufferedWriter
extends java.io.Writer
FileChannel that delays actually writing to or closing the
buffer if a transaction is active. If a transaction is detected on the call
to Writer.write(String) the parameter is buffered and passed on to the
underlying writer only when the transaction is committed.| Constructor and Description |
|---|
TransactionAwareBufferedWriter(java.nio.channels.FileChannel channel,
java.lang.Runnable closeCallback)
Create a new instance with the underlying file channel provided, and a callback
to execute on close.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
long |
getBufferSize()
Convenience method for clients to determine if there is any unflushed
data.
|
void |
setEncoding(java.lang.String encoding) |
void |
setForceSync(boolean forceSync)
Flag to indicate that changes should be force-synced to disk on flush.
|
void |
write(char[] cbuf,
int off,
int len) |
void |
write(java.lang.String str,
int off,
int len) |
public TransactionAwareBufferedWriter(java.nio.channels.FileChannel channel,
java.lang.Runnable closeCallback)
channel - channel used to do the actual file IOcloseCallback - callback to execute on closepublic void setEncoding(java.lang.String encoding)
public void setForceSync(boolean forceSync)
forceSync - the flag value to setpublic long getBufferSize()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOExceptionpublic void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOException