Class FileIO
- java.lang.Object
-
- com.trivago.cluecumber.engine.filesystem.FileIO
-
@Singleton public class FileIO extends Object
This class manages reading from and writing to files.
-
-
Constructor Summary
Constructors Constructor Description FileIO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisExistingFile(String filePath)Check if a file exists.StringreadContentFromFile(String filePath)Read string content from a file.voidwriteContentToFile(byte[] content, String filePath)Write byte array content to a file.voidwriteContentToFile(String content, String filePath)Write string content to a file.
-
-
-
Method Detail
-
writeContentToFile
public void writeContentToFile(String content, String filePath) throws FileCreationException
Write string content to a file.- Parameters:
content- the string content to be written.filePath- the complete path to the target file.- Throws:
FileCreationException- aFileCreationExceptionin case the file cannot be created.
-
writeContentToFile
public void writeContentToFile(byte[] content, String filePath) throws FileCreationExceptionWrite byte array content to a file.- Parameters:
content- the byte array content to be written.filePath- the complete path to the target file.- Throws:
FileCreationException- aFileCreationExceptionin case the file cannot be created.
-
readContentFromFile
public String readContentFromFile(String filePath) throws MissingFileException
Read string content from a file.- Parameters:
filePath- the complete path to the source file.- Returns:
- the file contents as a string.
- Throws:
MissingFileException- aMissingFileExceptionin case the file does not exist.
-
isExistingFile
public boolean isExistingFile(String filePath)
Check if a file exists.- Parameters:
filePath- the complete path to the file.- Returns:
- true if the file exists.
-
-