Class TempFiles

java.lang.Object
dev.architectury.loom.util.TempFiles
All Implemented Interfaces:
Closeable, AutoCloseable

public final class TempFiles extends Object implements Closeable
A helper for temporary files and directories that cleans up when closed by deleting all created temp files.
  • Constructor Details

    • TempFiles

      public TempFiles()
  • Method Details

    • directory

      public Path directory(@Nullable String prefix) throws IOException
      Creates a temporary directory.
      Parameters:
      prefix - a prefix for the directory's name
      Returns:
      the created directory
      Throws:
      IOException
    • file

      public Path file(@Nullable String prefix, @Nullable String suffix) throws IOException
      Creates a temporary file.
      Parameters:
      prefix - a prefix for the file's name
      suffix - a suffix for the file's name
      Returns:
      the created file
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException