Class FileUtility

java.lang.Object
org.serviceconnector.util.FileUtility

public final class FileUtility extends Object
The Class FileUtility.
  • Method Details

    • exists

      public static boolean exists(String filename)
      Exists.
      Parameters:
      filename - the filename
      Returns:
      true if the given file exists
    • belongsToDate

      public static boolean belongsToDate(File file, Date date)
      Check if give file belongs to current date (day)
      Parameters:
      file -
      date -
      Returns:
    • isFileLocked

      public static boolean isFileLocked(String filename)
      Checks if is file locked.
      Parameters:
      filename - the filename
      Returns:
      true, if is file locked
    • locate

      public static URL locate(String resourceName)
      Locate.
      Parameters:
      resourceName - the resource name
      Returns:
      the uRL
    • locateFromAbsolutePath

      public static URL locateFromAbsolutePath(String resourceName)
      Locate from absolute path.
      Parameters:
      resourceName - the resource name
      Returns:
      the uRL
    • locateFromCurrentClasspath

      public static URL locateFromCurrentClasspath(String resourceName)
      Locate from current classpath.
      Parameters:
      resourceName - the resource name
      Returns:
      the uRL
    • notExists

      public static boolean notExists(String filename)
      Not exists.
      Parameters:
      filename - the filename
      Returns:
      true if the given file does not exist
    • notExistsOrUnlocked

      public static boolean notExistsOrUnlocked(String filename)
      Not exists or unlocked.
      Parameters:
      filename - the filename
      Returns:
      true if the given file does not exist
    • waitExists

      public static void waitExists(String filename, int nrSeconds) throws Exception
      Parameters:
      filename - to look for
      nrSeconds - to wait (check is done in 1 second interval)
      Throws:
      Exception - if the file does not exist after the given time
    • waitExistsAndLocked

      public static void waitExistsAndLocked(String filename, int nrSeconds) throws Exception
      Parameters:
      filename - to look for
      nrSeconds - to wait (check is done in 1 second interval)
      Throws:
      Exception - if the file does not exist after the given time
    • waitNotExistsOrUnlocked

      public static void waitNotExistsOrUnlocked(String filename, int nrSeconds) throws Exception
      Parameters:
      filename - to look for
      nrSeconds - to wait (check is done in 1 second interval)
      Throws:
      Exception - if the file still exists after the given time
    • createPIDfileAndLock

      public static FileCtx createPIDfileAndLock(String fileNameFull) throws Exception
      Create file containing the PID. Is used for testing purpose to verify that process is running properly.
      Parameters:
      fileNameFull - the file name full
      Returns:
      the file ctx
      Throws:
      Exception - the exception
    • deleteFile

      public static void deleteFile(String fileNameFull)
      Delete file. Catch all possible errors
      Parameters:
      fileNameFull - the file name full
    • getLogPath

      public static String getLogPath() throws SCMPValidatorException
      Gets the log path.
      Returns:
      directory configured for appender in the current logback configuration file
      Throws:
      SCMPValidatorException - the sCMP validator exception
    • readFileToWriter

      public static void readFileToWriter(String filePath, Writer writer) throws IOException
      Read file to writer.
      Parameters:
      filePath - the file path
      writer - the writer
      Throws:
      IOException - Signals that an I/O exception has occurred.