Class MoveFileByteStore

  • All Implemented Interfaces:
    uk.ac.starlink.table.ByteStore

    public class MoveFileByteStore
    extends java.lang.Object
    implements uk.ac.starlink.table.ByteStore
    ByteStore that stores data in a named file which appears completely populated in the filesystem. This works in a similar way to FileByteStore, but it writes to a temporary file, and when it's complete it renames it to the requested destination file. The point of this is so that two copies of the same named file are being written at once, they will not interfere with each other.

    This implementation interferes slightly with the implicit contract of ByteStore, in that all the writing to the output stream has to be complete before a call to copy(java.io.OutputStream) or toByteBuffers(), but that's what you'd do in normal usage anyway.

    Since:
    8 Jan 2020
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      MoveFileByteStore​(java.io.File file)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void copy​(java.io.OutputStream out)  
      long getLength()  
      java.io.OutputStream getOutputStream()  
      java.nio.ByteBuffer[] toByteBuffers()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MoveFileByteStore

        public MoveFileByteStore​(java.io.File file)
                          throws java.io.IOException
        Constructor.
        Parameters:
        file - destination filename
        Throws:
        java.io.IOException
    • Method Detail

      • getOutputStream

        public java.io.OutputStream getOutputStream()
        Specified by:
        getOutputStream in interface uk.ac.starlink.table.ByteStore
      • getLength

        public long getLength()
        Specified by:
        getLength in interface uk.ac.starlink.table.ByteStore
      • copy

        public void copy​(java.io.OutputStream out)
                  throws java.io.IOException
        Specified by:
        copy in interface uk.ac.starlink.table.ByteStore
        Throws:
        java.io.IOException
      • toByteBuffers

        public java.nio.ByteBuffer[] toByteBuffers()
                                            throws java.io.IOException
        Specified by:
        toByteBuffers in interface uk.ac.starlink.table.ByteStore
        Throws:
        java.io.IOException
      • close

        public void close()
        Specified by:
        close in interface uk.ac.starlink.table.ByteStore