We can create temporary files in Java like in the code below
Here first argument is the name of our file we want to create and second argument is the extension of the file
We can have a third optional parameter as well that specifies the attributes of the file. But we don't need that for temp files.
try{Path tempFile = Files.createTempFile("myapp",".appext");
System.out.println("Temporary file path is "+tempFile.toAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}