Class FileUtils

java.lang.Object
io.sentry.util.FileUtils

@Internal public final class FileUtils extends Object
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • deleteRecursively

      public static boolean deleteRecursively(@Nullable @Nullable File file)
      Deletes the file or directory denoted by a path. If it is a directory, all files and directory inside it are deleted recursively. Note that if this operation fails then partial deletion may have taken place.
      Parameters:
      file - file or directory to delete
      Returns:
      true if the file/directory is successfully deleted, false otherwise
    • readText

      @Nullable public static @Nullable String readText(@Nullable @Nullable File file) throws IOException
      Reads the content of a File into a String. If the file does not exist or is not a file, null is returned. Do not use with large files, as the String is kept in memory!
      Parameters:
      file - file to read
      Returns:
      a String containing all the content of the file, or null if it doesn't exists
      Throws:
      IOException - In case of error reading the file
    • readBytesFromFile

      public static byte[] readBytesFromFile(String pathname, long maxFileLength) throws IOException, SecurityException
      Reads the content of a path into a byte array. If the path is does not exists, it's not a file, can't be read or is larger than max size allowed IOException is thrown. Do not use with large files, as the byte array is kept in memory!
      Parameters:
      pathname - file to read
      Returns:
      a byte array containing all the content of the file
      Throws:
      IOException - In case of error reading the file
      SecurityException