Class WritableLocalFileAccessor

All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, FileAccessor, NamedImplementation

public class WritableLocalFileAccessor extends LocalFileAccessor
Wraps a file, and manages a handle into that file. Supports positional read and write access.
  • Constructor Details

  • Method Details

    • write

      public final int write(@NotNull ByteBuffer buffer, long position)
      Description copied from interface: FileAccessor
      Write the supplied buffer (from buffer.position(), inclusive, to buffer.limit(), exclusive), starting at the supplied offset (position) into this file accessor.
      Parameters:
      buffer - A buffer with state appropriate for a call to FileChannel.write()
      position - The start position in this file accessor's data space to write to
      Returns:
      The number of bytes written, or -1 on error
    • truncate

      public final void truncate(long size)
      Description copied from interface: FileAccessor
      Truncate the file data space backing this accessor to the supplied size.
      Parameters:
      size - The new size
    • force

      public final void force()
      Description copied from interface: FileAccessor
      Make sure any previous writes to the underlying file through this file accessor are persisted, synchronously.
    • getImplementationName

      public final String getImplementationName()
      Description copied from interface: NamedImplementation

      Get a name for the implementing class. Useful for abstract classes that implement LogOutputAppendable or override toString.

      The default implementation is correct, but not suitable for high-frequency usage.

      Specified by:
      getImplementationName in interface NamedImplementation
      Overrides:
      getImplementationName in class LocalFileAccessor
      Returns:
      A name for the implementing class