Class KFile
java.lang.Object
ch.k43.util.KFile
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDelete a file or directory.static booleanCheck if file exists.static longReturn size of file.static byte[]readByteFile(String argFileName) Read file into byte array.static org.json.JSONObjectreadJSONFile(String argFileName) Read JSON file and parse content into org.json.JSONObject.static PropertiesreadPropertiesFile(String argFileName) Read properties file.static StringreadStringFile(String argFileName) Read file into string.static booleanRename a file or directory.toString()String representation of object.static booleanWrite bytes to file.static booleanWrite string to file.static booleanWrite JSON object to file.static booleanwritePropertiesFile(Properties argProperties, String argFileName) Write properties file.
-
Method Details
-
delete
Delete a file or directory.- Parameters:
argFileName- File or directory name- Returns:
- true if file or directory could be deleted, false otherwise
-
exists
Check if file exists.- Parameters:
argFileName- File or directory name- Returns:
- true if file or directory exist, false otherwise
-
getSize
Return size of file.- Parameters:
argFileName- File name- Returns:
- Size of file or -1 if not found
-
readByteFile
Read file into byte array.- Parameters:
argFileName- File name- Returns:
- Byte array with file content or empty buffer for errors
-
readJSONFile
Read JSON file and parse content into org.json.JSONObject.Note: The JSON-Java (org.json) library must be included at runtime.
- Parameters:
argFileName- File or directory name- Returns:
- JSON object with parsed JSON or null for errors
-
readPropertiesFile
Read properties file.- Parameters:
argFileName- File or directory name- Returns:
- Properties object or null for errors
- Since:
- 2024.05.17
-
readStringFile
-
rename
-
writeFile
Write bytes to file.- Parameters:
argBuffer- Byte array to be writtenargFileName- File name- Returns:
- True if successful, false otherwise
-
writeFile
Write JSON object to file.Note: The JSON-Java (org.json) library must be included at runtime.
- Parameters:
argJSONObject- org.json.JSONObject to be written outargFileName- File name- Returns:
- True if successful, false otherwise
-
writeFile
-
writePropertiesFile
Write properties file.- Parameters:
argProperties- Properties to be writtenargFileName- File or directory name- Returns:
- true if successful, false otherwise
- Since:
- 2024.05.17
-
toString
-