Here you can find the source of createTempFile()
public static Path createTempFile()
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; public class Main { public static Path createTempFile() { return createTempFile(null); }//from w w w .j av a 2s .c om public static Path createTempFile(String content) { try { Path tmpFile = Files.createTempFile("", null); if (content == null) Files.write(tmpFile, tmpFile.toString().getBytes("utf-8"), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); else Files.write(tmpFile, content.getBytes("utf-8"), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); return tmpFile; } catch (IOException ex) { ex.printStackTrace(); } return null; } }