Klasse GlobalFileSystemAccessor

java.lang.Object
ch.nolix.core.environment.filesystem.GlobalFileSystemAccessor

public final class GlobalFileSystemAccessor extends Object
The GlobalFileSystemAccessor can access the file system on the local machine.
Version:
2017-07-14
Autor:
Silvan Wyss
  • Methodendetails

    • getFolderOfRunningJarFile

      public static FolderAccessor getFolderOfRunningJarFile()
      Gibt zurück:
      a new FolderAccessor to the folder of the running jar file.
    • getFolderPathOfRunningJarFile

      public static String getFolderPathOfRunningJarFile()
      Gibt zurück:
      the path of the folder of the running jar file.
    • openInFileExplorer

      public static void openInFileExplorer(String path)
      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

      public static FileAccessor createFile(String path)
      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

      public static FileAccessor createFile(String path, WriteMode writeMode)
      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

      public static FileAccessor createFile(String path, WriteMode writeMode, byte[] content)
      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

      public static FileAccessor createFile(String path, WriteMode writeMode, String content)
      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

      public static FileAccessor createFile(String path, byte[] content)
      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

      public static FileAccessor createFile(String path, String content)
      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

      public static FolderAccessor createFolder(String path)
      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

      public static void deleteFileSystemItem(String path)
      Deletes the file system item with the given path if it exists.
      Parameter:
      path -
    • exists

      public static boolean exists(String path)
      Parameter:
      path -
      Gibt zurück:
      true if there exists a file system item with given path.
    • getFileAccessors

      public static IContainer<FileAccessor> getFileAccessors(String path)
      Parameter:
      path -
      Gibt zurück:
      new FileAccessors for the files in the folder with the given path.
    • getFileAccessors

      public static IContainer<FileAccessor> getFileAccessors(String path, String extension)
      Parameter:
      path -
      extension -
      Gibt zurück:
      new FileAccessors for the files in the folder with the given path, that have the given extension.
    • getFileAccessorsRecursively

      public static LinkedList<FileAccessor> getFileAccessorsRecursively(String path)
      Parameter:
      path -
      Gibt zurück:
      new FileAccessors for the files in the folder with the given path recursively.
    • getFileSystemItemAccessors

      public static IContainer<FileSystemItemAccessor> getFileSystemItemAccessors(String path)
      Parameter:
      path -
      Gibt zurück:
      new FileSystemItemAccessors for the file system items in the folder with the given path.
    • isFile

      public static boolean isFile(String path)
      Parameter:
      path -
      Gibt zurück:
      true if there exists a file with the given path.
    • isFolder

      public static boolean isFolder(String path)
      Parameter:
      path -
      Gibt zurück:
      true if there exists a folder with the given path.
    • overwriteFile

      public static void overwriteFile(String path, byte[] content)
    • overwriteFile

      public static void overwriteFile(String path, String content)
      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

      public static byte[] readFileToBytes(String filePath)
      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

      public static LinkedList<String> readFileToLines(String path)
      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.