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

public class FileUtil
extends java.lang.Object
Helper class for reading data from files.
Author:
Lukas Lukovsky, lukas.lukovsky@wultra.com
  • Constructor Summary

    Constructors
    Constructor Description
    FileUtil()  
  • Method Summary

    Modifier and Type Method Description
    static <T> T readDataFromFile​(StepLogger stepLogger, java.lang.String filePath, java.lang.Class<T> cls, java.lang.String logFileId, java.lang.String fileDescription)
    Reads data from a provided file
    static byte[] readFileBytes​(StepLogger stepLogger, java.lang.String filePath, java.lang.String logFileId, java.lang.String fileDescription)
    Read the contents of a provided data file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FileUtil

      public FileUtil()
  • Method Details

    • readFileBytes

      public static byte[] readFileBytes​(StepLogger stepLogger, @Nullable java.lang.String filePath, java.lang.String logFileId, java.lang.String fileDescription) throws java.io.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:
      java.io.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, java.lang.String filePath, java.lang.Class<T> cls, java.lang.String logFileId, java.lang.String fileDescription) throws java.lang.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:
      java.lang.Exception - when an error during file data reading occurred