@NotThreadSafe
public abstract class SafeOutputStream
extends java.io.OutputStream
implements java.nio.channels.WritableByteChannel, java.io.Closeable
SafeFiles.createAtomicFile(Path)| Constructor and Description |
|---|
SafeOutputStream() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
close()
If
commit() as been called, this method is a NO-OP. |
abstract void |
commit()
Commit causes the current atomic file writing operation to conclude
and the current temp file is safely promoted to being the canonical file.
|
abstract int |
write(java.nio.ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.
|
public abstract int write(@Nonnull
java.nio.ByteBuffer src)
throws java.io.IOException
Unlike the contract of WritableByteChannel, the ENTIRE buffer
is written to the channel (behaving like writeFully).
write in interface java.nio.channels.WritableByteChannelsrc - The buffer to flush.java.io.IOException - in the event that the buffer could not be written.public abstract void commit()
throws java.io.IOException
It is safe to call close()} after commit.
write(java.nio.ByteBuffer) or OutputStream.flush() however.java.io.IOException - in the event that the data could not be committed.public abstract void close()
throws java.io.IOException
commit() as been called, this method is a NO-OP. Otherwise...
Close causes the current atomic file writing operation to abort and the current temp file to be erased.
It is NOT safe to call any of the variations onwrite(java.nio.ByteBuffer) or OutputStream.flush() however.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in class java.io.OutputStreamjava.io.IOException - in the event that the output stream cannot be closed.