Package com.softwaremining.platformutils
Class FileUtility
java.lang.Object
com.softwaremining.platformutils.FileUtility
contains utility methods used internally by SoftwareMining framework
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleandeleteFile(String filePath) static final StringdotsToSlashes(String packageName) convers a package name to directory name delimited by forward slashes.static voidforceDirectory(String serOutDir) static final StringSet-up the Input/Output directory for creation of sequential files.static StringgetFileExtension(String fileName) return the file extensionstatic StringgetResource(String fileName, String resourceLabel) static final StringgetResourceAbsolutePath(String resourceName) static final InputStreamgetResourceAsStream(String resourceName) load the resoucesName using default contextClassLoader from current threadstatic final StringgetResourceAsString(String resourceName) Load the resource Name using the supplied classLoader, if fail then use class loader from current threadstatic final PropertiesloadProperties(String propertyFileRelativePath) load a property file from propertyFileRelativePath (in Classpath).static booleanrenameFile(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:
-
deleteFile
-
getResource
-
getFileExtension
return the file extension- Parameters:
fileName-- Returns:
-