Class FileUtils

java.lang.Object
io.github.the_sdet.files.FileUtils

public class FileUtils extends Object
This class handles all File Handling related Utilities and Helper methods
Author:
Pabitra Swain ([email protected])
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • checkFileExistence

      public static boolean checkFileExistence(String fileNameWithPath)
      checks existence of a file
      Parameters:
      fileNameWithPath - provide file name with path
      Returns:
      true/false - returns true if the file exists
    • cleanOrCreateDirectory

      public static void cleanOrCreateDirectory(String folderPath)
      This method deletes the files and folders inside a directory
      Parameters:
      folderPath - folder path
    • copyFile

      public static void copyFile(File source, File destination)
      Copies a file from the source to the destination.
      Parameters:
      source - The source file.
      destination - The destination file.
    • copyFile

      public static void copyFile(File source, File destination, String metadata)
      Copies a file from the source to the destination with metadata.
      Parameters:
      source - The source file.
      destination - The destination file.
      metadata - The metadata information.
    • byteArrayToFile

      public static File byteArrayToFile(byte[] data, String type)
      Converts a byte array to a file.
      Parameters:
      data - The byte array data.
      type - jpg/png
      Returns:
      The file created from the byte array.
    • fileNameWithTimeStamp

      public static String fileNameWithTimeStamp(String fileName, String timeStampPattern)
      creates filename appending timestamp
      Parameters:
      fileName - provide filename
      timeStampPattern - provide time stamp pattern
      Returns:
      Custom filename