Class BinaryDataFileRandomAccess

java.lang.Object
org.apache.jena.dboe.base.file.BinaryDataFileRandomAccess
All Implemented Interfaces:
org.apache.jena.atlas.lib.Closeable, org.apache.jena.atlas.lib.Sync, BinaryDataFile

public class BinaryDataFileRandomAccess extends Object implements BinaryDataFile
Implementation of BinaryDataFile using RandomAccessFile.
  • No buffering of reads or writes provided.
  • Not thread-safe.
  • See Also:
    • Constructor Summary

      Constructors
      Constructor
      Description
       
    • Method Summary

      Modifier and Type
      Method
      Description
      void
       
      boolean
      Is it open?
      long
      Return the length of the file (including any buffered writes)
      void
      Open the file
      int
      read(long posn, byte[] b, int start, int length)
      Read into a byte array, returning the number of bytes read.
      void
       
      void
      truncate(long length)
      Truncate the file
      long
      write(byte[] b, int start, int length)
      Write bytes - bytes are always written to the end of the file.

      Methods inherited from class java.lang.Object

      equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

      Methods inherited from interface org.apache.jena.dboe.base.file.BinaryDataFile

      isEmpty, read, write
    • Constructor Details

      • BinaryDataFileRandomAccess

        public BinaryDataFileRandomAccess(String filename)
    • Method Details

      • open

        public void open()
        Description copied from interface: BinaryDataFile
        Open the file
        Specified by:
        open in interface BinaryDataFile
      • isOpen

        public boolean isOpen()
        Description copied from interface: BinaryDataFile
        Is it open?
        Specified by:
        isOpen in interface BinaryDataFile
      • read

        public int read(long posn, byte[] b, int start, int length)
        Description copied from interface: BinaryDataFile
        Read into a byte array, returning the number of bytes read. Reads are at an absolute position and a read is atomic/thread-safe.
        Specified by:
        read in interface BinaryDataFile
        Parameters:
        posn - Location of the read operation.
        start - of bytesarray to read into
        length - Maximum number of bytes to read.
        Returns:
        The number of bytes read
      • write

        public long write(byte[] b, int start, int length)
        Description copied from interface: BinaryDataFile
        Write bytes - bytes are always written to the end of the file. Return the location where the write started.
        Specified by:
        write in interface BinaryDataFile
      • truncate

        public void truncate(long length)
        Description copied from interface: BinaryDataFile
        Truncate the file
        Specified by:
        truncate in interface BinaryDataFile
      • sync

        public void sync()
        Specified by:
        sync in interface BinaryDataFile
        Specified by:
        sync in interface org.apache.jena.atlas.lib.Sync
      • close

        public void close()
        Specified by:
        close in interface BinaryDataFile
        Specified by:
        close in interface org.apache.jena.atlas.lib.Closeable
      • length

        public long length()
        Description copied from interface: BinaryDataFile
        Return the length of the file (including any buffered writes)
        Specified by:
        length in interface BinaryDataFile