Class TempFiles

java.lang.Object
com.axelor.file.temp.TempFiles

public class TempFiles extends Object
  • Constructor Details

    • TempFiles

      public TempFiles()
  • Method Details

    • getTempPath

      public static Path getTempPath()
      Get the path to deal with temp upload file/dir
      Returns:
      the temp path
    • getRootTempPath

      public static Path getRootTempPath()
      Get the root path to deal with temp file/dir
      Returns:
      the root temp path
    • createTempFile

      public static Path createTempFile() throws IOException
      Create a temporary file.
      Returns:
      the path to the newly created file
      Throws:
      IOException - if an I/O error occurs
    • createTempFile

      public static Path createTempFile(String prefix, String suffix, FileAttribute<?>... attrs) throws IOException
      Create a temporary file.
      Parameters:
      prefix - the file prefix to use
      suffix - the file suffix to use
      attrs - an optional list of file attributes
      Returns:
      the path to the newly created file
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • findTempFile

      public static Path findTempFile(String name)
      Find a temporary file by the given name created previously.
      Parameters:
      name - name of the temp file
      Returns:
      file path
    • createTempDir

      public static Path createTempDir() throws IOException
      Create a temporary directory
      Returns:
      the path to the newly created directory
      Throws:
      IOException - if an I/O error occurs
    • createTempDir

      public static Path createTempDir(String prefix) throws IOException
      Create a temporary directory
      Parameters:
      prefix - the prefix string to be used in generating the directory's name
      Returns:
      the path to the newly created directory
      Throws:
      IOException - if an I/O error occurs
    • clean

      public static void clean(String fileId) throws IOException
      This method can be used to delete temporary file of an incomplete upload.
      Parameters:
      fileId - the upload file id
      Throws:
      IOException - if an I/O error occurs
    • clean

      public static void clean() throws IOException
      Clean up obsolete temporary files from upload directory.
      Throws:
      IOException - if an I/O error occurs