java.lang.Object
io.getlime.security.powerauth.lib.cmd.util.FileUtil

public class FileUtil extends Object
Helper class for reading data from files.
Author:
Lukas Lukovsky, lukas.lukovsky@wultra.com
  • 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 logger
      filePath - Path of the file
      cls - Class of the returned data
      logFileId - File id used for logging messages
      fileDescription - Description of the file
      Returns:
      File data converted to the desired type
      Throws:
      Exception - when an error during file data reading occurred