List of utility methods to do Temp File Create
String | getTempFileName() Create temp file name based on current datetime DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); return df.format(new Date()); |
File | getTempFileName(String base, String ext) Get a temporary file name, optionally prefixed by the base (if specified) and also optionally using the given extension (if specified, otherwise ".tmp" will be used). if (base == null || base.length() <= 0) base = ""; if (ext == null || ext.length() <= 0) ext = "tmp"; UUID uuid = UUID.randomUUID(); String tmpName = sanitizeFileName(base + uuid.toString() + '.' + ext); return new File(System.getProperty("java.io.tmpdir"), tmpName); |
String | getTempFileName(String fileExt) get Temp File Name SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSSS"); return sdf.format(new Date()) + fileExt; |
String | getTempFilePath(String name) get Temp File Path String file = ""; String tmpfilepath = System.getProperty("java.io.tmpdir") + File.separator; String tmpDiamondFilePath = "/dls/tmp/"; String username = System.getProperty("user.name"); File tmpDir = new File(tmpfilepath); boolean canWrite = tmpDir.canWrite(); if (canWrite) { File folderTmp = new File(tmpfilepath + username); ... |
String | getTempFilePath(String signatureRequestId) get Temp File Path return (System.getProperty("java.io.tmpdir") + "/signature_" + signatureRequestId + ".jpg"); |
Set | getTempFiles() get Temp Files return new HashSet<File>(tempFiles); |
List | getTempFileWithFullPath() get Temp File With Full Path File file = File.createTempFile("OnlineReport", ".pdf"); List<String> fileDetails = new ArrayList<String>(2); fileDetails.add(file.getParentFile().getAbsolutePath().replace("\\", "/")); fileDetails.add(file.getName()); file.delete(); return fileDetails; |
String | getUniqueAFileName(String ext) get Unique A File Name return String.format("%s-%s.%s", (new SimpleDateFormat("ddMMyy-hhmmss_SSS")).format(new Date()), (new Random()).nextInt(3), ext); |
File | getUniqueFile(File dir, String prefix, String suffix) Get an unique name under the specified directory String name = prefix + "." + FILENAME_FORMAT.format(new Date()) + "."; for (int i = 0; i < Integer.MAX_VALUE; i++) { File file = new File(dir, name + i + suffix); if (!file.exists()) { return file; return null; ... |
String | getUniqueFileName() get Unique File Name return new SimpleDateFormat("yyyy_MM_dd__HH_mm_ss_SSS").format(new Date(System.currentTimeMillis())); |