Create a new temporary file on the filesystem.
import java.io.File;
File tempFile = File.createTempFile("prefix-", "-suffix"); tempFile.deleteOnExit();
#include <stdlib.h>
const char tmpl[] = "XXXXXX.tmp"; int fd = mkstemp(tmpl);
(ns programming-idioms (:import [java.io File]))
(File/createTempFile "prefix" "suffix" (new File "/tmp"))
(File/createTempFile "prefix" "suffix")
using System.IO;
string file = Path.GetTempFileName();
import std.stdio;
auto f = File.tmpfile();
open (newunit=u,status="scratch")
import "os"
tmpfile, err := os.CreateTemp("", "")
import System.IO.Temp
withTempFile $ \f -> do -- do something with f
{ "dependencies": "tempy^1.0.1" } import tempy from 'tempy'
const tempFile = tempy.file()
const resultOfCallback = tempy.file.task(tempFile => { // do something with tempFile })
file = io.tmpfile()
$f = tmpfile();
uses sysutils;
var H: THandle; begin H := FileCreate(GetTempFileName); end.
use Path::Tiny qw(tempfile);
my $path = tempfile;
import File::Temp qw(tempfile);
my $fh = tempfile(); # or my ($fh, $filename) = tempfile();
import tempfile
file = tempfile.TemporaryFile()
require 'tempfile'
file = Tempfile.new('foo')
use tempdir::TempDir; use std::fs::File;
let temp_dir = TempDir::new("prefix")?; let temp_file = File::open(temp_dir.path().join("file_name"))?;
No security, no password. Other people might choose the same nickname.