Interface IStorage
- All Known Implementing Classes:
EcmStorage
public interface IStorage
Classes implementing the IStorage interface provide methods for file persistence.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
createFolder
(String path) Creates a folder.void
deleteFile
(String path) Deletes the specified file or folder.boolean
fileExists
(String path) Checks whether the specified path points to an existing file or folder.Gets the files and folders contained in the specified folder.boolean
Checks whether the specified path points to a folder.byte[]
Reads the content of the specified file.readFileAsString
(String path) Reads the content of the specified file.void
Writes data to the specified file.void
Writes data to the specified file.
-
Method Details
-
createFolder
Creates a folder.- Parameters:
path
- the path of the new folder- Throws:
IOException
- if an error occurred while accessing the storage
-
writeFile
Writes data to the specified file. The file will be overwritten if it already exists.- Parameters:
path
- the destination pathdata
- a byte array containing the data to write- Throws:
IOException
- if an error occurred while accessing the storage
-
writeFile
Writes data to the specified file. The file will be overwritten if it already exists.- Parameters:
path
- the destination pathdata
- a string containing the data to write- Throws:
IOException
- if an error occurred while accessing the storage
-
readFile
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
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
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
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
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
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
-