Klasse GlobalFileSystemAccessor
java.lang.Object
ch.nolix.core.environment.filesystem.GlobalFileSystemAccessor
The
GlobalFileSystemAccessor
can access the file system on the local
machine.- Version:
- 2017-07-14
- Autor:
- Silvan Wyss
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic FileAccessor
createFile
(String path) Creates a new empty file with the given path.static FileAccessor
createFile
(String path, byte[] content) Creates a new file with the given path.static FileAccessor
createFile
(String path, WriteMode writeMode) Creates a new empty file with the given path.static FileAccessor
createFile
(String path, WriteMode writeMode, byte[] content) Creates a new file with the given path.static FileAccessor
createFile
(String path, WriteMode writeMode, String content) Creates a new file with the given path.static FileAccessor
createFile
(String path, String content) Creates a new file with the given path.static FolderAccessor
createFolder
(String path) Creates a new empty folder with the given path.static void
deleteFileSystemItem
(String path) Deletes the file system item with the given path if it exists.static boolean
static IContainer
<FileAccessor> getFileAccessors
(String path) static IContainer
<FileAccessor> getFileAccessors
(String path, String extension) static LinkedList
<FileAccessor> static IContainer
<FileSystemItemAccessor> static FolderAccessor
static String
static boolean
static boolean
static void
Opens the folder of the running jar file in a new file explorer.static void
openInFileExplorer
(String path) Opens the folder with the given path in a new file explorer.static void
overwriteFile
(String path, byte[] content) static void
overwriteFile
(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 LinkedList
<String> readFileToLines
(String path) Reads the content of the file with the given path to lines.
-
Methodendetails
-
getFolderOfRunningJarFile
- Gibt zurück:
- a new
FolderAccessor
to 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
FileAccessor
to 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
FileAccessor
to 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_ALREADY
and 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
FileAccessor
to 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_ALREADY
and 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
FileAccessor
to 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_ALREADY
and 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
FileAccessor
to 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
FileAccessor
to 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
FileAccessor
to 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
FileAccessor
s for the files in the folder with the given path.
-
getFileAccessors
- Parameter:
path
-extension
-- Gibt zurück:
- new
FileAccessor
s for the files in the folder with the given path, that have the given extension.
-
getFileAccessorsRecursively
- Parameter:
path
-- Gibt zurück:
- new
FileAccessor
s for the files in the folder with the given path recursively.
-
getFileSystemItemAccessors
- Parameter:
path
-- Gibt zurück:
- new
FileSystemItemAccessor
s 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.
-