Package com.vivoka.vsdk.util
Class FileSystem
java.lang.Object
com.vivoka.vsdk.util.FileSystem
Utility class for working with file system
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringabsolutePath(String filePath) Converts a relative path to an absolute path.static StringBuilds a path from the given parts.static booleanisAbsolutePath(String filePath) Checks if the given path is absolute.static org.json.JSONObjectloadJsonObjectFromAssets(String filePath) Loads a json file from assets and returns it as aJSONObject.static org.json.JSONObjectloadJsonObjectFromStorage(String filePath) Loads a json file from storage and returns it as aJSONObject.static StringreadFileFromAssets(String filePath) Reads a file from assets and returns its content as a string.static StringreadFileFromStorage(String filePath) Reads a file from storage and returns its content as a string.
-
Constructor Details
-
FileSystem
public FileSystem()
-
-
Method Details
-
getPath
Builds a path from the given parts.- Parameters:
first- First part of the path.more- Additional parts of the path.- Returns:
- Built path
-
isAbsolutePath
Checks if the given path is absolute.- Parameters:
filePath- Path to check- Returns:
trueif the path is absolute,falseotherwise
-
absolutePath
Converts a relative path to an absolute path.- Parameters:
filePath- Relative path- Returns:
- Absolute path
- Throws:
Exception- If the conversion fails
-
loadJsonObjectFromStorage
Loads a json file from storage and returns it as aJSONObject.- Parameters:
filePath- Path to the json file- Returns:
- Parsed json
- Throws:
Exception- If failed to parse the json
-
loadJsonObjectFromAssets
Loads a json file from assets and returns it as aJSONObject.- Parameters:
filePath- Path to the json file in assets- Returns:
- Parsed json
- Throws:
Exception- If failed to parse the json
-
readFileFromStorage
Reads a file from storage and returns its content as a string.- Parameters:
filePath- Path to the file- Returns:
- File content
- Throws:
Exception- If failed to read the file
-
readFileFromAssets
Reads a file from assets and returns its content as a string.- Parameters:
filePath- Path to the file in assets- Returns:
- File content
- Throws:
Exception- If failed to read the file
-