Secure temporary file: Difference between revisions

→‎{{header|Kotlin}}: Change to use more secure method
(→‎{{header|Kotlin}}: Change to use more secure method)
Line 395:
 
=={{header|Kotlin}}==
<syntaxhighlight lang="scalakotlin">//import version 1kotlin.io.1path.2createTempFile
import kotlin.io.path.deleteExisting
 
fun main() {
import java.io.File
val tftempFilePath = File.createTempFile("tempexample", ".tmp")
 
println("Temporary file created: $tempFilePath")
fun main(args: Array<String>) {
tempFilePath.deleteExisting()
try {
val tf = File.createTempFile("temp", ".tmp")
println(tf.absolutePath)
tf.delete()
}
catch (ex: Exception) {
println(ex.message)
}
}</syntaxhighlight>
Sample output (Ubuntu v14.04):
{{out}}
<pre>
Temporary file created: /tmp/example14437465325231438926.tmp
/tmp/temp1551492276377305257.tmp
</pre>
 
44

edits