Package de.qytera.qtaf.core.io
Class FileHelper
java.lang.Object
de.qytera.qtaf.core.io.FileHelper
Class containing helper methods for handling files
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancreateFileIfNotExists(String filePath, String fileContent) Create a filestatic booleanDelete a filestatic booleanCheck if a file existsstatic byte[]getFileContent(String filepath) Get file contentstatic StringgetFileContentAsUTF8String(String filepath) Get file content as Stringstatic booleanCreate an empty file and all its parent directoriesstatic voidWrite file
-
Constructor Details
-
FileHelper
public FileHelper()
-
-
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
-
delete
Delete a file- Parameters:
filePath- File location- Returns:
- true on success, false otherwise
-