Class FileHelper

java.lang.Object
de.qytera.qtaf.core.io.FileHelper

public class FileHelper extends Object
Class containing helper methods for handling files.
  • Method Details

    • exists

      public static boolean exists(String filePath)
      Check if a file exists.
      Parameters:
      filePath - File location
      Returns:
      true if exists, false otherwise
    • touch

      public static boolean touch(String filePath)
      Create an empty file and all its parent directories.
      Parameters:
      filePath - File location
      Returns:
      true on success, false otherwise
    • createFileIfNotExists

      public static boolean createFileIfNotExists(String filePath, String fileContent) throws IOException
      Create a file.
      Parameters:
      filePath - File path relative to project's root directory
      fileContent - File content
      Returns:
      true on success, false otherwise
      Throws:
      IOException - error during file creation
    • getFileContent

      public static byte[] getFileContent(String filepath) throws IOException
      Get file content.
      Parameters:
      filepath - path to file
      Returns:
      file content
      Throws:
      IOException - File not found
    • getFileContentAsUTF8String

      public static String getFileContentAsUTF8String(String filepath) throws IOException
      Get file content as String.
      Parameters:
      filepath - path to file
      Returns:
      file content
      Throws:
      IOException - File not found
    • writeFile

      public static void writeFile(String filePath, String content) throws IOException
      Write file.
      Parameters:
      filePath - File location
      content - File content
      Throws:
      IOException - file not writable
    • delete

      public static boolean delete(String filePath)
      Delete a file.
      Parameters:
      filePath - File location
      Returns:
      true on success, false otherwise