List of utility methods to do File Name Create
String | fileName(String filename) file Name String name = ""; int i = filename.lastIndexOf('.'); int p = Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')); if (i > p) { name = filename.substring(0, i); return name; |
String | filename(String filename) filename return filename.replaceFirst("^~/", System.getProperty("user.home") + "/"); |
String | fileName(String name) Return filename sans extension. String fname = pathName(name); int index = name.indexOf("."); if (index > 0) fname = fname.substring(0, index); return fname; |
String | filename(String name) filename final String basename = basename(name); final int idx = basename.indexOf('.'); if (idx >= 0 && idx < basename.length()) { return basename.substring(0, idx); return name; |
String | filename(String name, String ext) Simply concatenates name with extension using dot. return name + "." + ext; |
String | fileName(String path) returns the filename from the given path int pos = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')); if (pos > 0) { return path.substring(pos + 1); return path; |
String | fileName(String path) extract a file name from 'path' path = normalize(path); return path.substring(path.lastIndexOf('/') + 1); |
String | fileName(String path) file Name if (path.endsWith("/")) { throw new IllegalArgumentException("path cannot end with a slash"); int indexOfLastSeparator = path.lastIndexOf('/'); if (indexOfLastSeparator == -1) { throw new IllegalArgumentException("path does not contain any slashes"); return path.substring(indexOfLastSeparator + 1); ... |
String | filename(String prefix, String sep, String index) Construct a filename return String.format("%s%s%s", prefix, sep, index); |
String | FileName(String[] args) File Name String name = null; for (int i = 0; i < args.length; i++) { if (i == 0) { name = args[i]; } else { name = name + "_" + args[i]; return name.toLowerCase() + ".txt"; |