Android File Temp Create createTempFile()

Here you can find the source of createTempFile()

Description

create Temp File

Declaration

public static File createTempFile() throws IOException 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class Main {
    public static File createTempFile() throws IOException {
        return createFileInFolder(tempFolder(), UUID.randomUUID()
                .toString());/*from w  ww .ja  v a  2 s.  com*/
    }

    public static File createFileInFolder(File folder, String fileName)
            throws IOException {
        File file = removeableFile(folder, fileName);
        file.createNewFile();
        return file;
    }

    private static File tempFolder() {
        return new File(tempFolderName());
    }

    private static File removeableFile(File folder, String fileName) {
        File file = new File(folder, fileName);
        file.deleteOnExit();
        return file;
    }

    private static String tempFolderName() {
        return System.getProperty("java.io.tmpdir");
    }
}

Related

  1. aTempFile()
  2. createTemp(File file)
  3. createTemp(String path)
  4. createTempFile(File baseDir, String fileName)
  5. createTempFile(String filePrefix, String fileSuffix)
  6. createTempFile(String pFilename)
  7. getTempFile()