List of utility methods to do Temp File Create
String | getUniqueFilename(String filename, String extension) get Unique Filename return filename + "_" + getCurrentDateAsString("yyyy_MM_dd_HH_mm_ss_SSS") + "." + extension; |
String | getUniqueFileName(String fileNamePrefix, String fileExtension) get Unique File Name Date d = Calendar.getInstance().getTime(); long now = System.currentTimeMillis(); return "QTIScoringEngine_" + fileNamePrefix + "_" + DateFormat.getDateInstance(DateFormat.SHORT).format(d).replace("/", "-") + "_" + DateFormat.getTimeInstance(DateFormat.LONG).format(d).replace(" ", "").replace(":", "_") + fileExtension; |
String | getUniqueFileName(String originalFileName) Gets a unique file name, based on the fileName with the time in milliseconds added before the file extension., This works with all file types including directories. int index = originalFileName.lastIndexOf('.'); if (index < 0) index = originalFileName.length(); String suffix = originalFileName.substring(index); originalFileName = originalFileName.replace(suffix, ""); String newFileName = originalFileName + "_" + getDateTimeMilliSecondEnsureUnique() + suffix; return newFileName; |
File | getUniqueTempFile(final boolean autoDelete, final File parentFolder, final String suffix) get Unique Temp File final File tmpFile = File.createTempFile( "test_" + new SimpleDateFormat("ddMMMyyyy-HHmmss").format(new Date()), suffix, parentFolder); if (autoDelete) { tmpFile.deleteOnExit(); return tmpFile; |
File | newTmpFile(String content) Creates a new temporary file using the default encoding of ISO-8859-1 (Latin1). return newTmpFile(content, "ISO-8859-1"); |
File | newTmpFile(String content, String encoding) Makes a new temporary file and writes content into it. Writer out = null; Reader in = null; File f = null; try { f = File.createTempFile("jspwiki", null); in = new StringReader(content); out = new OutputStreamWriter(new FileOutputStream(f), encoding); copyContents(in, out); ... |