Class RMFileUtils

java.lang.Object
com.inductiveautomation.rm.base.RMFileUtils

public class RMFileUtils extends Object
Utility methods for file.
  • Constructor Details

    • RMFileUtils

      public RMFileUtils()
  • Method Details

    • getFile

      public static File getFile(Object aSource)
      Returns a File object from a source, if one can be divined.
    • getPath

      public static String getPath(File aFile)
      Returns the path for a file.
    • getFileName

      public static String getFileName(File aFile)
      Returns the file name for a file.
    • getFileNameSimple

      public static String getFileNameSimple(File aFile)
      Returns the file name for a file.
    • getFileExtension

      public static String getFileExtension(File aFile)
      Returns the file name for a file.
    • isFileType

      public static boolean isFileType(File aFile, String... theTypes)
      Returns whether file is given type.
    • getDirectory

      public static File getDirectory(File aParent, String aChild, boolean create)
      Returns a child directory for a parent directory, creating if necessary.
    • openFile

      public static void openFile(File aFile)
      Tries to open the given file name with the platform reader.
    • openFile

      public static void openFile(String aName)
      Tries to open the given file name with the platform reader.
    • getBytes

      public static byte[] getBytes(File aFile)
      Returns bytes for a file.
    • writeBytes

      public static void writeBytes(@Nonnull File aFile, @Nullable byte[] theBytes) throws IOException
      Writes the given bytes (within the specified range) to the given file.
      Throws:
      IOException
    • writeBytesSafely

      public static void writeBytesSafely(File aFile, byte[] theBytes) throws IOException
      Writes the given bytes (within the specified range) to the given file, with an option for doing it "safely".
      Throws:
      IOException
    • getTempDir

      public static File getTempDir()
      Returns the temp directory.
    • getTempFile

      public static File getTempFile(String aName)
      Creates a file in the temp directory.
    • getUserHomeDir

      public static File getUserHomeDir(String aName, boolean doCreate)
      Returns a file for named directory in the user's home directory (with option to create).
    • getAppDataDir

      public static File getAppDataDir(String aName, boolean doCreate)
      Returns the AppData or Application Support directory file.
    • copyFile

      public static File copyFile(File aSource, File aDest) throws IOException
      Copies a file from one location to another.
      Throws:
      IOException
    • copyFileSafe

      public static File copyFileSafe(File in, File out)
      Copies a file from one location to another with exception suppression.
    • deleteDeep

      public static boolean deleteDeep(File aFile)
      Deletes a directory.
    • unzip

      public static void unzip(File aFile)
      Unzips the given file into the destination file.
    • getUnpackDestination

      public static File getUnpackDestination(File aFile, File aDestFile)
      Returns the file that given packed file would be saved to using the unpack method.
    • getUniqueFile

      public static File getUniqueFile(File aFile)
      Returns a unique non-existent file for given file.