List of utility methods to do File Name Create
String | addTimeStampGetPostFix(Date now, TimeUnit unit) add Time Stamp Get Post Fix if (unit == TimeUnit.MINUTES) { return new SimpleDateFormat("yyyy-MM-dd_HH:mm").format(now); } else if (unit == TimeUnit.HOURS) { return new SimpleDateFormat("yyyy-MM-dd_HH").format(now); } else if (unit == TimeUnit.DAYS) { return new SimpleDateFormat("yyyy-MM-dd").format(now); } else { throw new IllegalArgumentException(unit.toString()); ... |
String | addTimestampToFilename(Date date, String fileName) Adds the timestamp to filename. String[] time = getTimeFormat(date, "yyyy-MM-dd.HH-mm").split("\\."); return time[0] + "/" + time[1] + fileName; |
String | addTimestampToFilename(String fileName) add Timestamp To Filename int pos = fileName.lastIndexOf('.'); String prefix = fileName; String suffix = ""; if (pos != -1) { prefix = fileName.substring(0, pos); suffix = fileName.substring(pos); String newFileName = prefix + timestampForFile() + suffix; ... |
String | addTimeStampToFileName(String name) add Time Stamp To File Name SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yy 'at' HH.mm.ss", Locale.ENGLISH); Date currentDate = new Date(); String formattedDate = dateFormat.format(currentDate); int index = name.lastIndexOf("."); String mainFName; if (index != -1) { mainFName = name.substring(0, index - 1) + " " + formattedDate + name.substring(index - 1, name.length()); ... |
String | fileName(Class> clazz) file Name return clazz.getName().replace('.', '/') + ".class"; |
String | filename(final String path) Return the filename part of a path. int i = path.lastIndexOf('/'); return (i < 0) ? path : path.substring(i + 1); |
String | fileName(String contentFile) file Name if (contentFile == null || contentFile.isEmpty()) { return ""; int i1 = contentFile.lastIndexOf("/"); int i2 = contentFile.lastIndexOf("\\"); if (i1 > 0 || i2 > 0) { return contentFile.substring(Math.max(i1, i2) + 1); return contentFile; |
String | fileName(String file) Get the file name minus its suffix int index = file.lastIndexOf("."); if (index != -1) return file.substring(0, index); else return file; |
String | fileName(String file, String moduleName) file Name String name = file.replaceAll("_drupal_safe_name_", moduleName); return name; |
String | filename(String filename) filename int dot = filename.lastIndexOf("."); if (dot == -1) { return filename; return filename.substring(0, dot); |