Package io.sentry.util
Class FileUtils
java.lang.Object
io.sentry.util.FileUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
deleteRecursively
(@Nullable File file) Deletes the file or directory denoted by a path.static byte[]
readBytesFromFile
(String pathname, long maxFileLength) Reads the content of a path into a byte array.static @Nullable String
Reads the content of a File into a String.
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
deleteRecursively
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
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 fileSecurityException
-