Here you can find the source of createTempFile(final String file, final String ext)
private static File createTempFile(final String file, final String ext) throws IOException
//package com.java2s; /*/* w w w . j a va2 s . c o m*/ * Copyright (c) 2010 Jardin Development Group <jardin.project@gmail.com>. * * Jardin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Jardin is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jardin. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static File createTempFile(final String file, final String ext) throws IOException { File f = new File(file); String filename = f.getName(); /* Aggancia la data al nome del file */ if (filename == null) { filename = "export"; } SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddhhmm"); String date = formatter.format(new Date()); // TODO effettuare la traslitterazione del nome del file filename = filename + "_" + date + "_"; filename = filename.replace(' ', '.'); filename = filename.replace('/', '.'); // filename = filename.replace('\\', '.'); filename = filename.toLowerCase(); return File.createTempFile(filename, "." + ext, f.getParentFile()); } }