Below java code shows how to create Temp File in java
[java]
/****************************************************************************************
* Created on 08-2011 Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.javaio;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
/**
* Created by https://kodehelp.com
* Date: 8/27/11
*/
public class CreateTempFile {
public static void main(String args[]){
try {
File tempFile = File.createTempFile("demo",".tmp");
FileOutputStream fout = new FileOutputStream(tempFile);
PrintStream out = new PrintStream(fout);
out.println("This is sample text in the temporary file which is created");
} catch (IOException e) {
e.printStackTrace();
}
}
}
[/java]