Class MoveFileByteStore

java.lang.Object
uk.ac.starlink.ttools.plot2.data.MoveFileByteStore
All Implemented Interfaces:
uk.ac.starlink.table.ByteStore

public class MoveFileByteStore extends 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 Details

    • MoveFileByteStore

      public MoveFileByteStore(File file) throws IOException
      Constructor.
      Parameters:
      file - destination filename
      Throws:
      IOException
  • Method Details

    • getOutputStream

      public 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(OutputStream out) throws IOException
      Specified by:
      copy in interface uk.ac.starlink.table.ByteStore
      Throws:
      IOException
    • toByteBuffers

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

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