file createTempFile1 Example
file class createTempFile example. This example shows you how to use createTempFile method.
File class createTempFile example. method returns abstract pathnames of every newly created .tmp file in the default temporary-file directory.method is being called by a File class object.method uses prefix value to give name to file and suffix value to define its file type or extension.if suffix is passed null it takes .tmp as suffix value by default.
Here is the code:-
/**
* @Program uses createTempFile method to create empty '.tmp' files
* in the default temporary-file directory and generating abstract
* pathnames of every newly created.
* CreateNewFile.java
* Author:-RoseIndia Team
* Date:-30-june-2008
*/
import java.io.*;
public class CreateTempFile1 {
public static void main(String args[]) throws IOException {
File x = new File("");
File y = new File("");
System.out.println("Absract path names:");
System.out.println(x.createTempFile("baadshah", null));
System.out.println(y.createTempFile("khan", null));
}
} |
Output of the program:-
Absract path names:
/tmp/baadshah27963.tmp
/tmp/khan27964.tmp |
|