Class FileUtility

java.lang.Object
com.softwaremining.platformutils.FileUtility

public class FileUtility extends Object
contains utility methods used internally by SoftwareMining framework
  • Field Details

    • logger

      protected static transient Log logger
  • Constructor Details

    • FileUtility

      public FileUtility()
  • Method Details

    • dotsToSlashes

      public static final String dotsToSlashes(String packageName)
      convers a package name to directory name delimited by forward slashes. For example
      com.softwaremining.util
      will be translated to com/softwaremining/util
      Parameters:
      packageName -
      Returns:
    • getResourceAsStream

      public static final InputStream getResourceAsStream(String resourceName)
      load the resoucesName using default contextClassLoader from current thread
      Parameters:
      resourceName -
      Returns:
    • getResourceAbsolutePath

      public static final String getResourceAbsolutePath(String resourceName)
    • loadProperties

      public static final Properties loadProperties(String propertyFileRelativePath)
      load a property file from propertyFileRelativePath (in Classpath). If properties is not found, it will not cause a problem, it will return an empty property file
      Parameters:
      resourceName -
      Returns:
    • getResourceAsString

      public static final String getResourceAsString(String resourceName)
      Load the resource Name using the supplied classLoader, if fail then use class loader from current thread
      Parameters:
      resourceName -
      classLoader -
      Returns:
    • getDataDirectory

      public static final String getDataDirectory()
      Set-up the Input/Output directory for creation of sequential files. if running in a web-environment (WEB-INF somewhere in the path) The method needs "softwaremining.properties" file somewhere it its path.
      Returns:
      if WEB-INF is somewhere in the path then it absolute path for "WEB-INF/out" if WEB-INF is not anywhere in the path - then it returns "";
    • forceDirectory

      public static void forceDirectory(String serOutDir)
    • renameFile

      public static boolean renameFile(String oldName, String newName)
      rename a file - overwrites if a file with new name exists
      Parameters:
      oldName -
      newName -
      Returns:
    • getResource

      public static String getResource(String fileName, String resourceLabel)
    • getFileExtension

      public static String getFileExtension(String fileName)
      return the file extension
      Parameters:
      fileName -
      Returns: