Package herddb.utils

Class ManagedFile

  • All Implemented Interfaces:
    AutoCloseable

    public class ManagedFile
    extends Object
    implements AutoCloseable
    A "managed" file that give access to underlying OutputStream for write operations and permit to sync to disk flushed data.
    Author:
    diego.salvi
    • Method Detail

      • open

        public static ManagedFile open​(Path path,
                                       boolean requirefsync,
                                       StandardOpenOption... options)
                                throws IOException
        Opens or creates a file, returning a ManagedFile that may be used to write bytes to the file.

        If no options are present then this method works as if the CREATE, TRUNCATE_EXISTING, and WRITE options are present. In other words, it opens the file for writing, creating the file if it doesn't exist, or initially truncating an existing regular-file to a size of 0 if it exists.

        Parameters:
        path -
        requirefsync -
        options -
        Returns:
        Throws:
        IOException
      • open

        public static ManagedFile open​(Path path,
                                       boolean requirefsync,
                                       Set<? extends OpenOption> options,
                                       FileAttribute<?>... attrs)
                                throws IOException
        Opens or creates a file, returning a ManagedFile that may be used to write bytes to the file.

        If no options are present then this method works as if the CREATE, TRUNCATE_EXISTING, and WRITE options are present. In other words, it opens the file for writing, creating the file if it doesn't exist, or initially truncating an existing regular-file to a size of 0 if it exists.

        Parameters:
        path -
        options -
        attrs -
        Returns:
        Throws:
        IOException
      • getOutputStream

        public OutputStream getOutputStream()
        Returns the OutputStream that can be used to write to the file
        Returns:
        file output stream