Package org.moeaframework.analysis.store
Class TransactionalOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.moeaframework.analysis.store.TransactionalOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Output stream with a transaction mechanism requiring one to call
commit() before the content is stored.
The typical use is:
try (TransactionalOutputStream out = blob.openOutputStream()) {
out.write(...);
out.commit();
}
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a transactional output stream. -
Method Summary
Methods inherited from class java.io.FilterOutputStream
flush, write, write, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
TransactionalOutputStream
Constructs a transactional output stream.- Parameters:
out- the temporary output stream, where content is written before it is committed
-
-
Method Details
-
commit
Indicates the content was successfully written. This method must be called beforeclose()to take effect.- Throws:
IOException- if an I/O error occurred
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
doCommit
Called duringclose()to commit or complete the transaction.- Throws:
IOException- if an I/O error occurred
-
doRollback
Called duringclose()to rollback the transaction.- Throws:
IOException- if an I/O error occurred
-