createTempFile

Platform and version requirements: JVM (1.0)
fun createTempFile(
    prefix: String = "tmp", 
    suffix: String? = null, 
    directory: File? = null
): File

Creates a new empty file in the specified directory, using the given prefix and suffix to generate its name.

If prefix is not specified then some unspecified string will be used. If suffix is not specified then ".tmp" will be used. If directory is not specified then the default temporary-file directory will be used.

The prefix argument, if specified, must be at least three characters long. It is recommended that the prefix be a short, meaningful string such as "job" or "mail".

To create the new file, the prefix and the suffix may first be adjusted to fit the limitations of the underlying platform.

Exceptions

IOException - in case of input/output error.

IllegalArgumentException - if prefix is shorter than three symbols.

Return a file object corresponding to a newly-created file.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/create-temp-file.html