Interface BackupStorage

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
FileSystemBackupStorage

public interface BackupStorage extends Closeable
A backup storage is responsible for writing and reading backup files in a persistent location. This interface does not support nested structures like sub-directories. Backup files are identified with file names, implementations should take into consideration that these names may contain any characters allowed by file systems for file names.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
     
    void
    Deletes the file with the provided name.
    boolean
    exists(String fileName)
    Tests whether this storage contains a file with the provided name.
    Returns a stream containing the existing file names.
    Opens an input stream for reading the file with the provided name.
    Opens an output stream for writing data to the file with the provided name.
  • Method Details

    • exists

      boolean exists(String fileName)
      Tests whether this storage contains a file with the provided name.
      Parameters:
      fileName - the name of the file.
      Returns:
      whether this storage contains a file with the provided name.
    • deleteIfExists

      void deleteIfExists(String fileName) throws IOException
      Deletes the file with the provided name.
      Parameters:
      fileName - the name of the file to be deleted.
      Throws:
      IOException - if an I/O error occurs.
    • list

      Stream<String> list() throws IOException
      Returns a stream containing the existing file names.
      Returns:
      a stream containing the existing file names.
      Throws:
      IOException - if an I/O error occurs.
    • newInputStream

      InputStream newInputStream(String fileName) throws IOException
      Opens an input stream for reading the file with the provided name. The stream will not be buffered and is not required to support the InputStream.mark(int) or InputStream.reset() methods.
      Parameters:
      fileName - the name of the file to be read.
      Returns:
      a new input stream.
      Throws:
      IOException - if an I/O error occurs.
    • newOutputStream

      OutputStream newOutputStream(String fileName) throws IOException
      Opens an output stream for writing data to the file with the provided name. If the file already exists, the data is overwritten, otherwise a new file is created. The resulting stream will not be buffered.
      Parameters:
      fileName - the name of the file to write data to.
      Returns:
      a new output stream.
      Throws:
      IOException - if an I/O error occurs.
    • close

      default void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable