Package de.qytera.qtaf.core.io
Class FileHelper
java.lang.Object
de.qytera.qtaf.core.io.FileHelper
Class containing helper methods for handling files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancreateFileIfNotExists(String filePath, String fileContent) Create a file.static booleanDelete a file.static booleanCheck if a file exists.static byte[]getFileContent(String filepath) Get file content.static StringgetFileContentAsUTF8String(String filepath) Get file content as String.static booleanCreate an empty file and all its parent directories.static voidWrite file.
-
Method Details
-
exists
Check if a file exists.- Parameters:
filePath- File location- Returns:
- true if exists, false otherwise
-
touch
Create an empty file and all its parent directories.- Parameters:
filePath- File location- Returns:
- true on success, false otherwise
-
createFileIfNotExists
Create a file.- Parameters:
filePath- File path relative to project's root directoryfileContent- File content- Returns:
- true on success, false otherwise
- Throws:
IOException- error during file creation
-
getFileContent
Get file content.- Parameters:
filepath- path to file- Returns:
- file content
- Throws:
IOException- File not found
-
getFileContentAsUTF8String
Get file content as String.- Parameters:
filepath- path to file- Returns:
- file content
- Throws:
IOException- File not found
-
writeFile
Write file.- Parameters:
filePath- File locationcontent- File content- Throws:
IOException- file not writable
-
delete
Delete a file.- Parameters:
filePath- File location- Returns:
- true on success, false otherwise
-