Overview
Package
Class
Use
Tree
Deprecated
Index
All Classes
Help
Prev Class
Next Class
VUtils – Release 1
Interface org.violetlib.io.TransactionalOutputStream
Inherited members: ShowHide
Deprecated: ShowHide
org.violetlib.io

Interface TransactionalOutputStream

  • All Superinterfaces:
    AutoCloseable, Closeable, IOTransactional, Transactional, VOutputStream
    public interface TransactionalOutputStream extends VOutputStream, IOTransactional
    A transactional output stream.

    This interface defines two methods that terminate a transactional output operation. These methods change the state of the transactional output stream to terminated. In the terminated state, invocations of these methods have no effect and invocations of output operations throw an IllegalStateException.

    The terminating methods are commit() and abort(). The commit method must be called after the intended contents have been written to make the contents available, for example, as a new file. Otherwise, the abort method must be called, both to ensure that temporary resources are released and to ensure that a subsequent invocation of commit(), even by accident, has no effect.

    The above description means that one may call commit() after calling abort() or call abort() after calling commit(); in either case, the second method invocation will have no effect. Thus, it is possible and convenient to call commit() at the end of a try body and call abort() in a finally clause of the same try statement. Even more conveniently, if the transactional writer is created and used within a try-with-resources statement, no explicit invocation of abort() is required, because it will be called implicitly (as close() is defined to call abort()).

    • Methods 
      Modifier and Type Method and Description
      Ordinary member indicator abort Reveal DetailHide Detail
      abstract void abort()
      This method has no effect if the output stream has already been committed or aborted.
      void abort()
      This method has no effect if the output stream has already been committed or aborted. Otherwise, abort the output operation so that (if possible) no partial effects are visible.
      Specified by:
      abort in interface IOTransactional
      Specified by:
      abort in interface Transactional
      Ordinary member indicator close Reveal DetailHide Detail
      void close()
      The close method is defined to invoke the abort method.
      void close() throws IOException
      The close method is defined to invoke the abort method. This behavior allows a transactional output stream to be used in a try-with-resources statement with no explicit invocation of abort().
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface IOTransactional
      Specified by:
      close in interface Transactional
      Throws:
      IOException
      Ordinary member indicator commit Reveal DetailHide Detail
      abstract void commit()
      This method has no effect if the output stream has already been committed or aborted.
      void commit() throws IOException
      This method has no effect if the output stream has already been committed or aborted. Otherwise, make the previously written contents available as appropriate, for example, in a new file.
      Specified by:
      commit in interface IOTransactional
      Specified by:
      commit in interface Transactional
      Throws:
      IOException - if the attempt to make the contents available failed.
      Inherited member indicator flush Reveal DetailHide Detail
      abstract void flush()
       
      void flush() throws IOException
      Inherited member indicator write Reveal DetailHide Detail
      void write(byte[] b)
       
      void write(byte[] b) throws IOException
      Inherited member indicator write Reveal DetailHide Detail
      abstract void write(byte[] b, int off, int len)
       
      void write(byte[] b, int off, int len) throws IOException
      Inherited member indicator write Reveal DetailHide Detail
      abstract void write(int b)
       
      void write(int b) throws IOException