Package ch.k43.util

Klasse KFile

java.lang.Object
ch.k43.util.KFile

public class KFile extends Object
Static class with a collection of file utility methods.
  • Methodendetails

    • delete

      public static boolean delete(String argFileName)
      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

      public static boolean exists(String argFileName)
      Check if file exists.
      Parameter:
      argFileName - File or directory name
      Gibt zurück:
      true if file or directory exist, false otherwise
    • getSize

      public static long getSize(String argFileName)
      Return size of file.
      Parameter:
      argFileName - File name
      Gibt zurück:
      Size of file or -1 if not found
    • readByteFile

      public static byte[] readByteFile(String argFileName)
      Read file into byte array.
      Parameter:
      argFileName - File name
      Gibt zurück:
      Byte array with file content or null for errors
    • readJSONFile

      public static org.json.JSONObject readJSONFile(String argFileName)
      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

      public static Properties readPropertiesFile(String argFileName)
      Read properties file.
      Parameter:
      argFileName - File or directory name
      Gibt zurück:
      Properties object or null for errors
      Seit:
      2024.05.17
    • readStringFile

      public static String readStringFile(String argFileName)
      Read file into string.
      Parameter:
      argFileName - File name
      Gibt zurück:
      String with file content or null for errors
    • rename

      public static boolean rename(String argOldFileName, String argNewFileName)
      Rename a file or directory.
      Parameter:
      argOldFileName - File or directory name
      argNewFileName - File or directory name
      Gibt zurück:
      True if file or directory could be renamed, false otherwise
    • writeFile

      public static boolean writeFile(byte[] argBuffer, String argFileName)
      Write bytes to file.
      Parameter:
      argBuffer - Byte array to be written
      argFileName - File name
      Gibt zurück:
      True if successful, false otherwise
    • writeFile

      public static boolean writeFile(org.json.JSONObject argJSONObject, String argFileName)
      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 out
      argFileName - File name
      Gibt zurück:
      True if successful, false otherwise
    • writeFile

      public static boolean writeFile(String argString, String argFileName)
      Write string to file.
      Parameter:
      argString - String to be written to file
      argFileName - File name
      Gibt zurück:
      True if successful, false otherwise
    • writePropertiesFile

      public static boolean writePropertiesFile(Properties argProperties, String argFileName)
      Write properties file.
      Parameter:
      argProperties - Properties to be written
      argFileName - File or directory name
      Gibt zurück:
      true if successful, false otherwise
      Seit:
      2024.05.17
    • toString

      public String toString()
      String representation of object.
      Setzt außer Kraft:
      toString in Klasse Object
      Seit:
      2024.08.23