Class FolderAccessor
java.lang.Object
ch.nolix.base.environment.filesystem.FileSystemItemAccessor
ch.nolix.base.environment.filesystem.FolderAccessor
A
FolderAccessor can access a folder.- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsItem(String relativePath) createFile(String relativePath) Creates a new empty file with the given relative path in the folder of the currentFolderAccessor.createFolder(String relativePath) Creates a new empty folder with the given relative path in the folder of the currentFolderAccessor.voiddeleteFileSystemItem(String relativePath) Deletes the file system item with the given relative path from the folder of the currentFolderAccessorif it exists.static FolderAccessorforFolderPath(String folderPath) getFileAccessors(String extension) getFileAccessorsRecursively(String extension) getFolderAccessor(String relativePath) voidOpens the folder of the currentFolderAccessorin a new file explorer.Reads the content of the file with the given relative path.Methods inherited from class FileSystemItemAccessor
getExtension, getName, getParentFolderAccessor, getPath, getSizeInBytes, hasExtension, isFile, isFolder, openParentFolder, withPath
-
Method Details
-
forFolderPath
- Parameters:
folderPath-- Returns:
- a new
FolderAccessorfor the folder for the given folderPath. - Throws:
RuntimeException- if there does not exist a folder with the given folderPath in the file system on the local machine.
-
containsItem
- Parameters:
relativePath-- Returns:
- true if the folder of the current
FolderAccessorcontains an item with the given relative path, false otherwise.
-
createFile
Creates a new empty file with the given relative path in the folder of the currentFolderAccessor.- Parameters:
relativePath-- Returns:
- a new
FileAccessorfor the created file. - Throws:
RuntimeException- if there exists already a file system item with the given relative path in the folder of the currentFolderAccessor.
-
createFolder
Creates a new empty folder with the given relative path in the folder of the currentFolderAccessor.- Parameters:
relativePath-- Returns:
- a new
FolderAccessorfor the created folder. - Throws:
RuntimeException- if there exists alreay a file system item with the given relative path in the folder of the currentFolderAccessor.
-
deleteFileSystemItem
Deletes the file system item with the given relative path from the folder of the currentFolderAccessorif it exists.- Parameters:
relativePath-
-
getFileAccessors
- Returns:
- new
FileAccessors for the files in the folder of the currentFolderAccessor.
-
getFileAccessors
- Parameters:
extension-- Returns:
- a new
FileAccessors for the files in the folder of the currentFolderAccessor, that have the given extension.
-
getFileAccessorsRecursively
- Parameters:
extension-- Returns:
- new
FileAccessorfor the files in the folder of the currentFolderAccessor, that have the given extension, recursively.
-
getFileAccessorsRecursively
- Returns:
- new
FileAccessorfor the files in the folder of the currentFolderAccessorrecursively.
-
getFileSystemItemAccessors
- Returns:
- new
FileSystemItemAccessors to the file system items in the folder of the currentFolderAccessor.
-
getFolderAccessor
- Parameters:
relativePath-- Returns:
- a new
FolderAccessorfor the folder with the given relative path in the folder of the currentFolderAccessor.
-
openInFileExplorer
public void openInFileExplorer()Opens the folder of the currentFolderAccessorin a new file explorer. -
readFile
Reads the content of the file with the given relative path.- Parameters:
relativePath-- Returns:
- the content of the file with the given relative path.
- Throws:
RuntimeException- if there does not exist a file with the given relative path in the folder of the currentFolderAccessor.RuntimeException- if an error occurs.
-