Package com.toxicrain.rainengine.util
Class FileUtils
java.lang.Object
com.toxicrain.rainengine.util.FileUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getCurrentWorkingDirectory
(String relativePath) Converts a relative path to an absolute path based on the current working directory.static String
getCurrentWorkingDirectory
(String primaryPath, String fallbackPath) Converts a relative path to an absolute path based on the current working directory.static InputStream
getFileFromResourceAsStream
(String filePath) Deprecated.static long
getFileSize
(String filePath) Utility method to get the size of a file as a long.static String
Returns theSystem.getProperty(java.lang.String)
user.dirstatic String
Returns theSystem.getProperty(java.lang.String)
user.homestatic ByteBuffer
ioResourceToByteBuffer
(String resource) static String
Utility method to read the file content into a stringstatic void
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
getFileFromResourceAsStream
Deprecated. -
readFile
Utility method to read the file content into a string- Parameters:
filePath
- the path to the file- Returns:
- the content of the file as a string
- Throws:
IOException
- if an I/O error occurs
-
getFileSize
Utility method to get the size of a file as a long.- Parameters:
filePath
- the path to the file- Returns:
- the size of the file (in bytes) as a long
-
getUserHome
Returns theSystem.getProperty(java.lang.String)
user.home- Returns:
- System.getProperty("user.home")
-
getUserDir
Returns theSystem.getProperty(java.lang.String)
user.dir -
getCurrentWorkingDirectory
Converts a relative path to an absolute path based on the current working directory. If the path has been converted before, it returns the cached value.- Parameters:
relativePath
- the relative path to convert- Returns:
- the absolute path as a String
-
getCurrentWorkingDirectory
Converts a relative path to an absolute path based on the current working directory. Checks if the first path exists; if not, it uses the second path.- Parameters:
primaryPath
- the primary path to check and convertfallbackPath
- the fallback path to use if the primary path doesn't exist- Returns:
- the absolute path as a String
-
writeFile
- Throws:
IOException
-
ioResourceToByteBuffer
- Throws:
IOException
-