1 package gnu.kawa.functions; 2 import java.io.*; 3 import gnu.mapping.InPort; 4 5 public class FileUtils 6 { 7 8 10 11 public static 12 13 15 File createTempFile (String format) 16 throws java.io.IOException 17 { 18 if (format == null) 19 format = "kawa~d.tmp"; 20 int tilde = format.indexOf('~'); 21 String prefix, suffix; 22 File directory = null; 23 if (tilde < 0) 24 { 25 prefix = format; 26 suffix = ".tmp"; 27 } 28 else 29 { 30 prefix = format.substring(0, tilde); 31 suffix = format.substring(tilde+2); 32 } 33 int sep = prefix.indexOf(File.separatorChar); 34 if (sep >= 0) 35 { 36 directory = new File(prefix.substring(0, sep)); 37 prefix = prefix.substring(sep+1); 38 } 39 40 return File.createTempFile(prefix, suffix, directory); 41 42 56 } 57 } | Popular Tags |