Class KFile
java.lang.Object
ch.k43.util.KFile
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Delete a file or directory.static boolean
Check if file exists.static long
Return size of file.static byte[]
readByteFile
(String argFileName) Read file into byte array.static org.json.JSONObject
readJSONFile
(String argFileName) Read JSON file and parse content into org.json.JSONObject.static Properties
readPropertiesFile
(String argFileName) Read properties file.static String
readStringFile
(String argFileName) Read file into string.static boolean
Rename a file or directory.toString()
String representation of object.static boolean
Write bytes to file.static boolean
Write string to file.static boolean
Write JSON object to file.static boolean
writePropertiesFile
(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 null 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
-