Klasse FileUtils

java.lang.Object
de.dlr.proseo.storagemgr.utils.FileUtils

public class FileUtils extends Object
A utility class for common file operations. It provides methods to create, manipulate, and delete files and directories, along with supporting functionalities such as path handling and file property retrieval.
Autor:
Denys Chaykovskiy
  • Konstruktordetails

    • FileUtils

      public FileUtils(String path)
      Constructor sets the path
      Parameter:
      path - Path to file
  • Methodendetails

    • getPath

      public String getPath()
      Gets the path to file
      Gibt zurück:
      the path to file
    • setPath

      public void setPath(String path)
      Sets the path to file
      Parameter:
      path - the path to set
    • createFile

      public boolean createFile(String content)
      Creates the file with the content
      Parameter:
      content - Content of the file
      Gibt zurück:
      true if file was successfully created
    • synchroCreateFile

      public boolean synchroCreateFile(String content, long waitTime, long fileCheckMaxCycles)
      Creates the file with the content in a synchro modus
      Parameter:
      content - Content of the file
      waitTime - the wait time between each cycle of checking the file lock status
      fileCheckMaxCycles - file check max cycles
      Gibt zurück:
      true if file was successfully created
    • getFileSize

      public long getFileSize()
      Gets the file size
      Gibt zurück:
      the file size
    • isEmptyDirectory

      public boolean isEmptyDirectory()
      Checks if the path points to an empty directory
      Gibt zurück:
      true if directory is empty
    • getFileContent

      public String getFileContent()
      Gets the file content
      Gibt zurück:
      the content of the file
    • createParentDirectories

      public void createParentDirectories() throws IllegalArgumentException
      Create parent directories
      Löst aus:
      IllegalStateException - if cannot create dir
      IllegalArgumentException
    • createDirectories

      public void createDirectories() throws IllegalArgumentException
      Create path directories
      Löst aus:
      IllegalStateException - if cannot create dir
      IllegalArgumentException
    • deleteFile

      public String deleteFile() throws IOException
      Delete the file
      Gibt zurück:
      path to the deleted file
      Löst aus:
      IOException - if the file cannot be deleted
    • delete

      public List<String> delete() throws IOException
      Delete the file or the directory with its sub-directories and contained files
      Gibt zurück:
      the paths to the deleted files and directories
      Löst aus:
      IOException - if the file or directory cannot be deleted
    • deleteEmptyDirectoriesToTop

      public void deleteEmptyDirectoriesToTop(String directoryToDelete)
      Deletes empty directories recursively in the direction of root
      Parameter:
      directoryToDelete - the path to the directory