java.lang.Object
com.inductiveautomation.ignition.common.script.builtin.FileUtilities

public class FileUtilities extends Object
Functions for file system access, exposed as system.file.*.

These functions are available platform-wide.

  • Field Details

    • US_ASCII

      public static final String US_ASCII
    • ISO_8859_1

      public static final String ISO_8859_1
    • UTF_8

      public static final String UTF_8
    • UTF_16BE

      public static final String UTF_16BE
    • UTF_16LE

      public static final String UTF_16LE
    • UTF_16

      public static final String UTF_16
  • Constructor Details

    • FileUtilities

      public FileUtilities()
  • Method Details

    • getTempFile

      public static String getTempFile(String extension)
    • fileExists

      public static boolean fileExists(String filename)
    • writeFile

      public static void writeFile(String filename, byte[] data)
    • writeFile

      public static void writeFile(String filename, byte[] data, boolean append)
    • writeFile

      public static void writeFile(String filename, String data)
    • writeFile

      public static void writeFile(String filename, String data, boolean append)
    • writeFile

      public static void writeFile(String filename, String data, boolean append, String encoding)
      Writes data to a file.

      If the file or its parent directories do not exist, they will be created.

      Parameters:
      filename - The path to the file to write to.
      data - The string data to write.
      append - If true, the data will be appended to the end of the file instead of overwriting.
      encoding - The character encoding to use (e.g., "UTF-8"). If omitted, the platform default is used.
      Throws:
      org.python.core.PyException - with IOError if an error occurs during writing.
    • readFileAsString

      public static String readFileAsString(String filename)
    • readFileAsString

      public static String readFileAsString(String filename, String encoding)
      Reads the entire content of a file as a string.
      Parameters:
      filename - The path to the file to read.
      encoding - The character encoding to use (e.g., "UTF-8"). If omitted, the platform default is used.
      Returns:
      The content of the file as a string.
      Throws:
      org.python.core.PyException - with IOError if the file cannot be read.
    • readFileAsBytes

      public static byte[] readFileAsBytes(String filename)