Interface IStorage

  • All Known Implementing Classes:
    EcmStorage

    public interface IStorage
    Classes implementing the IStorage interface provide methods for file persistence.
    • Method Detail

      • createFolder

        void createFolder​(String path)
                   throws IOException
        Creates a folder.
        Parameters:
        path - the path of the new folder
        Throws:
        IOException - if an error occurred while accessing the storage
      • writeFile

        void writeFile​(String path,
                       byte[] data)
                throws IOException
        Writes data to the specified file. The file will be overwritten if it already exists.
        Parameters:
        path - the destination path
        data - a byte array containing the data to write
        Throws:
        IOException - if an error occurred while accessing the storage
      • writeFile

        void writeFile​(String path,
                       String data)
                throws IOException
        Writes data to the specified file. The file will be overwritten if it already exists.
        Parameters:
        path - the destination path
        data - a string containing the data to write
        Throws:
        IOException - if an error occurred while accessing the storage
      • readFile

        byte[] readFile​(String path)
                 throws FileNotFoundException
        Reads the content of the specified file.
        Parameters:
        path - the path to the file whose content will be read
        Returns:
        a byte array containing the file content
        Throws:
        FileNotFoundException - if the file could not be found
      • readFileAsString

        String readFileAsString​(String path)
                         throws FileNotFoundException
        Reads the content of the specified file.
        Parameters:
        path - the path to the file whose content will be read
        Returns:
        a string containing the file content
        Throws:
        FileNotFoundException - if the file could not be found
      • getFiles

        Set<String> getFiles​(String path)
                      throws IOException
        Gets the files and folders contained in the specified folder.
        Parameters:
        path - the path whose files and folders will be returned
        Returns:
        a set of file and folder names
        Throws:
        IOException - if an error occurred while accessing the storage
      • deleteFile

        void deleteFile​(String path)
        Deletes the specified file or folder.
        Parameters:
        path - the file or folder to delete
        Throws:
        IOException - if an error occurred while accessing the storage
      • isFolder

        boolean isFolder​(String path)
        Checks whether the specified path points to a folder.
        Parameters:
        path - the path to check
        Returns:
        true if the path points to a folder, otherwise false
      • fileExists

        boolean fileExists​(String path)
        Checks whether the specified path points to an existing file or folder.
        Parameters:
        path - the path to check
        Returns:
        true if the file or folder exists, otherwise false