Class TempFile

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Scalar<Path>

    public final class TempFile
    extends Object
    implements Scalar<Path>, Closeable
    A temporary file.

    These are ephemeral files to be used in small scopes. Typical use looks like this:

    
        try (final TempFile file = new TempFile()) {
           //write to the file
        }
     
    The physical file is deleted from the filesystem when the temp file is closed.
    Since:
    1.0
    • Constructor Detail

      • TempFile

        public TempFile()
        Ctor.

        Specifies empty strings for suffix and prefix, and creates the file in the filesystem's temporary directory denoted by the system property java.io.tmpdir.

        Since:
        1.0
      • TempFile

        public TempFile​(String prefix,
                        String suffix)
        Ctor.

        The temporary file will be created inside the filesystem's temporary folder (system property: java.io.tmpdir).

        Parameters:
        prefix - The temp filename's prefix
        suffix - The temp filename's suffix
        Since:
        1.0
      • TempFile

        public TempFile​(Text prefix,
                        Text suffix)
        Ctor.

        The temporary file will be created inside the filesystem's temporary folder (system property: java.io.tmpdir).

        Parameters:
        prefix - The temp filename's prefix
        suffix - The temp filename's suffix
        Since:
        1.0
      • TempFile

        public TempFile​(Scalar<Path> dir,
                        String prefix,
                        String suffix)
        Ctor.
        Parameters:
        dir - The directory in which to create the temp file
        prefix - The temp filename's prefix
        suffix - The temp filename's suffix
        Since:
        1.0
      • TempFile

        public TempFile​(Scalar<Path> dir,
                        Text prefix,
                        Text suffix)
        Ctor.
        Parameters:
        dir - The directory in which to create the temp file
        prefix - The temp filename's prefix
        suffix - The temp filename's suffix
        Since:
        1.0