Class Helper

java.lang.Object
de.swa.fuh.microsoft.control.Helper

public class Helper
extends java.lang.Object
main class to serve some reusable methods
  • Constructor Summary

    Constructors 
    Constructor Description
    Helper()  
  • Method Summary

    Modifier and Type Method Description
    static boolean CheckIfDirectoryExists​(java.lang.String _pathToFile)
    method to check if file by given path to file exists
    static boolean CheckIfFileExists​(java.lang.String _pathToFile)
    method to check if file by given path to file exists
    static void CompressImage​(java.io.File _file)
    method to compress images, focused on jpg images
    static boolean CreateDirIfNotExists​(java.lang.String _directory)
    method to create directory, if the directory is not yet created
    static java.util.Date GetDateFromString​(java.lang.String _dateString)
    String to date parser method, to get date object by given string
    static java.lang.String GetFileNameFromPath​(java.lang.String _path)
    method to extract filename from given string directory
    static java.util.List<java.io.File> GetFilePathListByDirectory​(java.lang.String _directory)
    method to collect all Files in directory
    static long GetImageSize​(java.io.File _file)
    method to return image size of given file
    static boolean IsImageSizeOk​(java.io.File _file)
    feedback method, if size is in given range
    static boolean WriteStringToFile​(java.lang.String _outputStream, java.lang.String _path, java.lang.String _fileName)
    method to write outputstream to file

    Methods inherited from class java.lang.Object

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

  • Method Details

    • CheckIfFileExists

      public static boolean CheckIfFileExists​(java.lang.String _pathToFile)
      method to check if file by given path to file exists
      Parameters:
      _pathToFile - is the filepath, which should be checked
      Returns:
      boolean return statement; true, if file exists, false if not
    • CheckIfDirectoryExists

      public static boolean CheckIfDirectoryExists​(java.lang.String _pathToFile)
      method to check if file by given path to file exists
      Parameters:
      _pathToFile - is the filepath, which should be checked
      Returns:
      boolean return statement; true, if file exists, false if not
    • WriteStringToFile

      public static boolean WriteStringToFile​(java.lang.String _outputStream, java.lang.String _path, java.lang.String _fileName)
      method to write outputstream to file
      Parameters:
      _outputStream - stream to write
      _path - path, in which the file with text should lay
      _fileName - filename, in which text should be written
      Returns:
      true if write action was successful, false if not
    • GetFilePathListByDirectory

      public static java.util.List<java.io.File> GetFilePathListByDirectory​(java.lang.String _directory)
      method to collect all Files in directory
      Parameters:
      _directory - path in which files stored
      Returns:
      List of File objects, found in directory; null if no files exists in path
    • CreateDirIfNotExists

      public static boolean CreateDirIfNotExists​(java.lang.String _directory)
      method to create directory, if the directory is not yet created
      Parameters:
      _directory - path of directory, which should be created
      Returns:
      true, if directory exusts or was created, false if not
    • GetImageSize

      public static long GetImageSize​(java.io.File _file)
      method to return image size of given file
      Parameters:
      _file - object to get size of
      Returns:
      long value of image size, zero if file not found
    • IsImageSizeOk

      public static boolean IsImageSizeOk​(java.io.File _file)
      feedback method, if size is in given range
      Parameters:
      _file - file to check for size
      Returns:
      boolean, if file size in range
    • CompressImage

      public static void CompressImage​(java.io.File _file)
      method to compress images, focused on jpg images
      Parameters:
      _file - file to compress
    • GetFileNameFromPath

      public static java.lang.String GetFileNameFromPath​(java.lang.String _path)
      method to extract filename from given string directory
      Parameters:
      _path - given path, from which filename should be extracted
      Returns:
      filename as string
    • GetDateFromString

      public static java.util.Date GetDateFromString​(java.lang.String _dateString)
      String to date parser method, to get date object by given string
      Parameters:
      _dateString - string to analyze
      Returns:
      date object or null if string could not be parsed