Package com.softwaremining.platformutils
Class FileUtility
java.lang.Object
com.softwaremining.platformutils.FileUtility
contains utility methods used internally by SoftwareMining framework
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
dotsToSlashes
(String packageName) convers a package name to directory name delimited by forward slashes.static void
forceDirectory
(String serOutDir) static final String
Set-up the Input/Output directory for creation of sequential files.static String
getFileExtension
(String fileName) return the file extensionstatic String
getResource
(String fileName, String resourceLabel) static final String
getResourceAbsolutePath
(String resourceName) static final InputStream
getResourceAsStream
(String resourceName) load the resoucesName using default contextClassLoader from current threadstatic final String
getResourceAsString
(String resourceName) Load the resource Name using the supplied classLoader, if fail then use class loader from current threadstatic final Properties
loadProperties
(String propertyFileRelativePath) load a property file from propertyFileRelativePath (in Classpath).static boolean
renameFile
(String oldName, String newName) rename a file - overwrites if a file with new name exists
-
Field Details
-
logger
-
-
Constructor Details
-
FileUtility
public FileUtility()
-
-
Method Details
-
dotsToSlashes
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
load the resoucesName using default contextClassLoader from current thread- Parameters:
resourceName
-- Returns:
-
getResourceAbsolutePath
-
loadProperties
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
Load the resource Name using the supplied classLoader, if fail then use class loader from current thread- Parameters:
resourceName
-classLoader
-- Returns:
-
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
-
renameFile
rename a file - overwrites if a file with new name exists- Parameters:
oldName
-newName
-- Returns:
-
getResource
-
getFileExtension
return the file extension- Parameters:
fileName
-- Returns:
-