Here you can find the source of saveToTempFile(File folder, String content, String fileType)
public static File saveToTempFile(File folder, String content, String fileType) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.UUID; public class Main { public static File saveToTempFile(File folder, String content, String fileType) throws IOException { String uuid = UUID.randomUUID().toString(); File f = new File(folder, uuid + "." + fileType); BufferedWriter out = new BufferedWriter(new FileWriter(f)); out.write(content);//from w w w. j a va 2s .c o m out.close(); return f; } }