Interface IFileRelativeIO

All Superinterfaces:
IPathRelativeIO
All Known Implementing Classes:
FileRelativeIO

public interface IFileRelativeIO extends IPathRelativeIO
An extended IPathRelativeIO version that uses files as the basis.
Since:
7.1.1
Author:
Philip Helger
  • Method Details

    • getBasePathFile

      @Nonnull File getBasePathFile()
      Returns:
      The base path. Never null.
    • getBasePath

      @Nonnull @Nonempty default String getBasePath()
      Specified by:
      getBasePath in interface IPathRelativeIO
      Returns:
      The absolute base path that is used. Neither null nor empty.
    • getFile

      @Nonnull default File getFile(@Nonnull String sRelativePath)
      Get a File relative to the base path.
      Parameters:
      sRelativePath - the relative path
      Returns:
      The "absolute" File and never null.
      See Also:
    • getResource

      @Nonnull default FileSystemResource getResource(@Nonnull String sRelativePath)
      Get the file system resource relative to the base path
      Specified by:
      getResource in interface IPathRelativeIO
      Parameters:
      sRelativePath - the relative path
      Returns:
      The "absolute" FileSystemResource and never null.
      See Also:
    • getRelativeFilename

      @Nullable default String getRelativeFilename(@Nonnull File aAbsoluteFile)
      Get the relative file name for the passed absolute file.
      Parameters:
      aAbsoluteFile - The non-null absolute file to make relative.
      Returns:
      null if the passed file is not a child of this base directory.
    • existsFile

      default boolean existsFile(@Nonnull String sRelativePath)
      Check if a file relative to the base path exists
      Parameters:
      sRelativePath - the relative path
      Returns:
      true if the File is a file and exists, false otherwise.
      See Also:
    • existsDir

      default boolean existsDir(@Nonnull String sRelativePath)
      Check if a directory relative to the base path exists
      Parameters:
      sRelativePath - the relative path
      Returns:
      true if the File is a directory and exists, false otherwise.
      See Also:
    • getOutputStream

      @Nullable default OutputStream getOutputStream(@Nonnull String sRelativePath)
      Get the OutputStream relative to the base path. An eventually existing file is truncated.
      Parameters:
      sRelativePath - the relative path
      Returns:
      null if the path is not writable
      See Also:
    • getOutputStream

      @Nullable default OutputStream getOutputStream(@Nonnull String sRelativePath, @Nonnull EAppend eAppend)
      Get the OutputStream relative to the base path
      Parameters:
      sRelativePath - the relative path
      eAppend - Append or truncate mode. May not be null.
      Returns:
      null if the path is not writable
      See Also:
    • getWriter

      @Nullable default Writer getWriter(@Nonnull String sRelativePath, @Nonnull Charset aCharset)
      Get the Writer relative to the base path. An eventually existing file is truncated.
      Parameters:
      sRelativePath - the relative path
      aCharset - The charset to use. May not be null.
      Returns:
      null if the path is not writable
      See Also:
    • getWriter

      @Nullable default Writer getWriter(@Nonnull String sRelativePath, @Nonnull Charset aCharset, @Nonnull EAppend eAppend)
      Get the Writer relative to the base path.
      Parameters:
      sRelativePath - the relative path
      aCharset - The charset to use. May not be null.
      eAppend - Append or truncate mode. May not be null.
      Returns:
      null if the path is not writable
      See Also:
    • createDirectory

      @Nonnull default FileIOError createDirectory(@Nonnull String sRelativePath, boolean bRecursive)
      Create the appropriate directory if it is not existing
      Parameters:
      sRelativePath - the relative path
      bRecursive - if true all missing parent directories will be created
      Returns:
      Success indicator. Never null.
      See Also:
    • deleteDirectory

      @Nonnull default FileIOError deleteDirectory(@Nonnull String sRelativePath, boolean bDeleteRecursively)
    • deleteDirectoryIfExisting

      @Nonnull default FileIOError deleteDirectoryIfExisting(@Nonnull String sRelativePath, boolean bDeleteRecursively)
    • deleteFile

      @Nonnull default FileIOError deleteFile(@Nonnull String sRelativePath)
    • deleteFileIfExisting

      @Nonnull default FileIOError deleteFileIfExisting(@Nonnull String sRelativePath)
    • renameDir

      @Nonnull default FileIOError renameDir(@Nonnull String sOldDirName, @Nonnull String sNewDirName)
    • renameFile

      @Nonnull default FileIOError renameFile(@Nonnull String sOldFilename, @Nonnull String sNewFilename)
    • writeFile

      @Nonnull default ESuccess writeFile(@Nonnull String sRelativePath, @Nonnull EAppend eAppend, @Nonnull byte[] aBytes)
      Helper function for saving a file with correct error handling.
      Parameters:
      sRelativePath - name of the file. May not be null.
      eAppend - Appending mode. May not be null.
      aBytes - the bytes to be written. May not be null.
      Returns:
      ESuccess
    • saveFile

      @Nonnull default ESuccess saveFile(@Nonnull String sRelativePath, @Nonnull String sContent, @Nonnull Charset aCharset)
      Helper function for saving a file with correct error handling.
      Parameters:
      sRelativePath - name of the file. May not be null.
      sContent - the content to save. May not be null.
      aCharset - The character set to use. May not be null.
      Returns:
      ESuccess
    • saveFile

      @Nonnull default ESuccess saveFile(@Nonnull String sRelativePath, byte[] aBytes)
      Helper function for saving a file with correct error handling.
      Parameters:
      sRelativePath - name of the file. May not be null.
      aBytes - the bytes to be written. May not be null.
      Returns:
      ESuccess
    • appendFile

      @Nonnull default ESuccess appendFile(@Nonnull String sRelativePath, @Nonnull String sContent, @Nonnull Charset aCharset)
      Helper function for saving a file with correct error handling.
      Parameters:
      sRelativePath - name of the file. May not be null.
      sContent - the content to save. May not be null.
      aCharset - The character set to use. May not be null.
      Returns:
      ESuccess
    • appendFile

      @Nonnull default ESuccess appendFile(@Nonnull String sRelativePath, @Nonnull byte[] aBytes)
      Helper function for saving a file with correct error handling.
      Parameters:
      sRelativePath - name of the file. May not be null.
      aBytes - the bytes to be written. May not be null.
      Returns:
      ESuccess