Class FileUtil
java.lang.Object
io.getlime.security.powerauth.lib.cmd.util.FileUtil
Helper class for reading data from files.
- Author:
- Lukas Lukovsky, lukas.lukovsky@wultra.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TreadDataFromFile(StepLogger stepLogger, String filePath, Class<T> cls, String logFileId, String fileDescription) Reads data from a provided filestatic byte[]readFileBytes(StepLogger stepLogger, String filePath, String logFileId, String fileDescription) Read the contents of a provided data file.
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
readFileBytes
public static byte[] readFileBytes(StepLogger stepLogger, @Nullable String filePath, String logFileId, String fileDescription) throws IOException, PowerAuthCmdException Read the contents of a provided data file.- Parameters:
stepLogger- Logger for error handling.filePath- Path of the file.logFileId- File id used for logging messages.fileDescription- Description of the file- Returns:
- Bytes with the contents of the file.
- Throws:
IOException- In case reading the file failed.PowerAuthCmdException- In case the filename is null or a file does not exist.
-
readDataFromFile
public static <T> T readDataFromFile(StepLogger stepLogger, String filePath, Class<T> cls, String logFileId, String fileDescription) throws Exception Reads data from a provided file- Type Parameters:
T- Class type of the returned data- Parameters:
stepLogger- Step loggerfilePath- Path of the filecls- Class of the returned datalogFileId- File id used for logging messagesfileDescription- Description of the file- Returns:
- File data converted to the desired type
- Throws:
Exception- when an error during file data reading occurred
-