Klasse FileSystemAccessor
java.lang.Object
ch.nolix.core.environment.filesystem.FileSystemAccessor
The
FileSystemAccessor can access the file system on the local
machine.- Version:
- 2017-07-14
- Autor:
- Silvan Wyss
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic FileAccessorcreateFile(String path) Creates a new empty file with the given path.static FileAccessorcreateFile(String path, byte[] content) Creates a new file with the given path.static FileAccessorcreateFile(String path, WriteMode writeMode) Creates a new empty file with the given path.static FileAccessorcreateFile(String path, WriteMode writeMode, byte[] content) Creates a new file with the given path.static FileAccessorcreateFile(String path, WriteMode writeMode, String content) Creates a new file with the given path.static FileAccessorcreateFile(String path, String content) Creates a new file with the given path.static FolderAccessorcreateFolder(String path) Creates a new empty folder with the given path.static voiddeleteFileSystemItem(String path) Deletes the file system item with the given path if it exists.static booleanstatic IContainer<FileAccessor> getFileAccessors(String path) static IContainer<FileAccessor> getFileAccessors(String path, String extension) static ILinkedList<FileAccessor> static IContainer<FileSystemItemAccessorUnit> static FolderAccessorstatic Stringstatic booleanstatic booleanstatic voidOpens the folder of the running jar file in a new file explorer.static voidopenInFileExplorer(String path) Opens the folder with the given path in a new file explorer.static voidoverwriteFile(String path, byte[] content) static voidoverwriteFile(String path, String content) Overwrites the file with the given path.static byte[]readFileToBytes(String filePath) Reads the content of the file with the given filePath to bytes.static ILinkedList<String> readFileToLines(String path) Reads the content of the file with the given path to lines.
-
Methodendetails
-
getFolderOfRunningJarFile
- Gibt zurück:
- a new
FolderAccessorto the folder of the running jar file.
-
getFolderPathOfRunningJarFile
- Gibt zurück:
- the path of the folder of the running jar file.
-
openInFileExplorer
Opens the folder with the given path in a new file explorer.- Parameter:
path-
-
openFolderOfRunningJarFileInExplorer
public static void openFolderOfRunningJarFileInExplorer()Opens the folder of the running jar file in a new file explorer. -
createFile
Creates a new empty file with the given path.- Parameter:
path-- Gibt zurück:
- a new
FileAccessorto the created file. - Löst aus:
ArgumentIsNullException- if the given path is null.EmptyArgumentException- if the given path is empty.InvalidArgumentException- if there exists already a file system item with the given path.
-
createFile
Creates a new empty file with the given path.- Parameter:
path-writeMode-- Gibt zurück:
- a new
FileAccessorto the created file. - Löst aus:
ArgumentIsNullException- if the given path is null.InvalidArgumentException- if the given path is blank.InvalidArgumentException- if the given writeMode flag =WriteMode.THROW_EXCEPTION_WHEN_TARGET_EXISTS_ALREADYand there exists already a file system item with the given path.
-
createFile
Creates a new file with the given path. The file will have the given content.- Parameter:
path-writeMode-content-- Gibt zurück:
- a new
FileAccessorto the created file. - Löst aus:
ArgumentIsNullException- if the given path is null.InvalidArgumentException- if the given path is blank.InvalidArgumentException- if the given writeMode =WriteMode.THROW_EXCEPTION_WHEN_TARGET_EXISTS_ALREADYand there exists already a file system item with the given path.ArgumentIsNullException- if the given content is null.
-
createFile
Creates a new file with the given path. The file will have the given content.- Parameter:
path-writeMode-content-- Gibt zurück:
- a new
FileAccessorto the created file. - Löst aus:
ArgumentIsNullException- if the given path is null.InvalidArgumentException- if the given path is blank.InvalidArgumentException- if the given writeMode =WriteMode.THROW_EXCEPTION_WHEN_TARGET_EXISTS_ALREADYand there exists already a file system item with the given path.ArgumentIsNullException- if the given content is null.
-
createFile
Creates a new file with the given path. The file will have the given content.- Parameter:
path-content-- Gibt zurück:
- a new
FileAccessorto the created file. - Löst aus:
ArgumentIsNullException- if the given path is null.EmptyArgumentException- if the given path is empty.InvalidArgumentException- if there exists already a file system item with the given path.
-
createFile
Creates a new file with the given path. The file will have the given content.- Parameter:
path-content-- Gibt zurück:
- a new
FileAccessorto the created file. - Löst aus:
ArgumentIsNullException- if the given path is null.InvalidArgumentException- if the given path is blank.InvalidArgumentException- if there exists already a file system item with the given path.
-
createFolder
Creates a new empty folder with the given path.- Parameter:
path-- Gibt zurück:
- a new
FileAccessorto the created folder. - Löst aus:
InvalidArgumentException- if there exists already a file system item with the given path.
-
deleteFileSystemItem
Deletes the file system item with the given path if it exists.- Parameter:
path-
-
exists
- Parameter:
path-- Gibt zurück:
- true if there exists a file system item with given path.
-
getFileAccessors
- Parameter:
path-- Gibt zurück:
- new
FileAccessors for the files in the folder with the given path.
-
getFileAccessors
- Parameter:
path-extension-- Gibt zurück:
- new
FileAccessors for the files in the folder with the given path, that have the given extension.
-
getFileAccessorsRecursively
- Parameter:
path-- Gibt zurück:
- new
FileAccessors for the files in the folder with the given path recursively.
-
getFileSystemItemAccessors
- Parameter:
path-- Gibt zurück:
- new
FileSystemItemAccessorUnits for the file system items in the folder with the given path.
-
isFile
- Parameter:
path-- Gibt zurück:
- true if there exists a file with the given path.
-
isFolder
- Parameter:
path-- Gibt zurück:
- true if there exists a folder with the given path.
-
overwriteFile
-
overwriteFile
Overwrites the file with the given path. Creates a new file with the given path if it does not exists. The file will get the given content.- Parameter:
path-content-- Löst aus:
InvalidArgumentException- if there exists already a folder with the given path.
-
readFileToBytes
Reads the content of the file with the given filePath to bytes.- Parameter:
filePath-- Gibt zurück:
- the bytes of the file with the given filePath.
- Löst aus:
InvalidArgumentException- if there does not exist a file with the given filePath in the file system on the local machine.
-
readFileToLines
Reads the content of the file with the given path to lines.- Parameter:
path-- Gibt zurück:
- the lines of the file with the given path.
- Löst aus:
InvalidArgumentException- if there does not exist a file with the given path.
-