Package ch.k43.util
Klasse KFile
java.lang.Object
ch.k43.util.KFile
Static class with a collection of file utility methods.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic 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.
-
Methodendetails
-
delete
Delete a file or directory.- Parameter:
argFileName
- File or directory name- Gibt zurück:
- true if file or directory could be deleted, false otherwise
-
exists
Check if file exists.- Parameter:
argFileName
- File or directory name- Gibt zurück:
- true if file or directory exist, false otherwise
-
getSize
Return size of file.- Parameter:
argFileName
- File name- Gibt zurück:
- Size of file or -1 if not found
-
readByteFile
Read file into byte array.- Parameter:
argFileName
- File name- Gibt zurück:
- 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.
- Parameter:
argFileName
- File or directory name- Gibt zurück:
- JSON object with parsed JSON or null for errors
-
readPropertiesFile
Read properties file.- Parameter:
argFileName
- File or directory name- Gibt zurück:
- Properties object or null for errors
- Seit:
- 2024.05.17
-
readStringFile
Read file into string.- Parameter:
argFileName
- File name- Gibt zurück:
- String with file content or null for errors
-
rename
Rename a file or directory.- Parameter:
argOldFileName
- File or directory nameargNewFileName
- File or directory name- Gibt zurück:
- True if file or directory could be renamed, false otherwise
-
writeFile
Write bytes to file.- Parameter:
argBuffer
- Byte array to be writtenargFileName
- File name- Gibt zurück:
- True if successful, false otherwise
-
writeFile
Write JSON object to file.Note: The JSON-Java (org.json) library must be included at runtime.
- Parameter:
argJSONObject
- org.json.JSONObject to be written outargFileName
- File name- Gibt zurück:
- True if successful, false otherwise
-
writeFile
Write string to file.- Parameter:
argString
- String to be written to fileargFileName
- File name- Gibt zurück:
- True if successful, false otherwise
-
writePropertiesFile
Write properties file.- Parameter:
argProperties
- Properties to be writtenargFileName
- File or directory name- Gibt zurück:
- true if successful, false otherwise
- Seit:
- 2024.05.17
-
toString
String representation of object.
-