Previous we just create empty temp file
Lets write there some text

Example:

1
2
3
4
5
6
7
8
try{
File tempFile = File.createTempFile("tempFile", ".tmp");
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(tempFile));
bufferedWriter.write("This is Test for tempFile!");
bufferedWriter.close();
}catch(IOException ex){
ex.printStackTrace();
}