Java tutorial
//package com.java2s; import java.io.File; public class Main { private static File createTempFile(String filename) { try { int dotIndex = filename.lastIndexOf("."); String prefix = filename.substring(0, dotIndex); String suffix = filename.substring(dotIndex + 1); File temp = File.createTempFile(prefix, suffix); temp.deleteOnExit(); return temp; } catch (Exception e) { throw new RuntimeException("Could not create temp file: " + filename, e); } } }