Klasse FileAccessor

java.lang.Object
ch.nolix.core.environment.filesystem.FileSystemItemAccessor
ch.nolix.core.environment.filesystem.FileAccessor

public final class FileAccessor extends FileSystemItemAccessor
A file accessor can access a given file.
Version:
2017-07-10
Autor:
Silvan Wyss
  • Konstruktordetails

    • FileAccessor

      public FileAccessor(String filePath)
      Creates a new file accessor for a file with the given file path.
      Parameter:
      filePath -
      Löst aus:
      InvalidArgumentException - if there does not exist a file with the given file path in the file system on the local machine.
  • Methodendetails

    • clearFile

      public void clearFile()
      Clears the file of this file accessor. Deletes the content of the file of this file accessor, but not the file itself.
    • overwriteFile

      public void overwriteFile(byte[] bytes)
      Overwrites the file of this file accessor with the given bytes.
      Parameter:
      bytes -
      Löst aus:
      RuntimeException - if an error occurs.
    • overwriteFile

      public void overwriteFile(String content)
      Overwrites the file of this file accessor with the given content.
      Parameter:
      content -
      Löst aus:
      RuntimeException - if an error occurs.
    • readFile

      public String readFile()
      Reads the content of the file of this file accessor.
      Gibt zurück:
      the content of the file of this file accessor.
      Löst aus:
      RuntimeException - if an error occurs.
    • readFileToBytes

      public byte[] readFileToBytes()
      Reads the content of the file of this file accessor to bytes.
      Gibt zurück:
      the bytes of the file of this file accessor.
      Löst aus:
      RuntimeException - if an error occurs.
    • readFileToLines

      public LinkedList<String> readFileToLines()
      Reads the content of the file of this file accessor to lines.
      Gibt zurück:
      the lines of the file of this file accessor.
      Löst aus:
      RuntimeException - if an error occurs.