File: createTempFile(String prefix, String suffix) : File « « Java by API

File: createTempFile(String prefix, String suffix)


public class MainClass {
  public static void main(String[] args) {
    try {
      File tempFile = File.createTempFile("myfile", ".tmp");
      FileOutputStream fout = new FileOutputStream(tempFile);
      PrintStream out = new PrintStream(fout);
      out.println("some text");
    } catch (IOException ex) {
      System.out.println("There was a problem creating/writing to the temp file");


Related examples in the same category

3.File: separatorChar File(String name) File(URI uri) File(String parent, String child)
7.File: canRead()
8.File: canWrite()
9.File: createNewFile()
10.File: delete()
11.File: deleteOnExit()
12.File: exists()
13.File: getAbsoluteFile()
14.File: getAbsolutePath()
15.File: getCanonicalPath()
16.File: getFreeSpace()
17.File: getName()
18.File: getParent()
19.File: getParentFile()
20.File: getPath()
21.File: getTotalSpace()
22.File: getUsableSpace()
23.File: isAbsolute()
24.File: isDirectory()
25.File: isFile()
26.File: listFiles()
27.File: isHidden()
28.File: lastModified()
29.File: length()
30.File: list()
31.File: listFiles(FilenameFilter filter)
32.File: listRoots()
33.File: mkdir()
34.File: mkdirs() (Creates a directory including any parent directories)
35.File: renameTo(File newFile)
36.File: setLastModified(long time)
37.File: setReadOnly()
38.File: setWritable(boolean writable)
39.File: toURI()
40.File: toURL()